Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
7db342c0
Commit
7db342c0
authored
Aug 18, 2018
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work around GCC 8's new -Wclass-memaccess.
parent
a0d44664
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
11 deletions
+54
-11
common.h
c++/src/capnp/common.h
+22
-10
layout.c++
c++/src/capnp/layout.c++
+10
-0
async-inl.h
c++/src/kj/async-inl.h
+11
-0
async-io-unix.c++
c++/src/kj/async-io-unix.c++
+0
-1
encoding.c++
c++/src/kj/encoding.c++
+11
-0
No files found.
c++/src/capnp/common.h
View file @
7db342c0
...
...
@@ -336,16 +336,28 @@ struct MessageSize {
using
kj
::
byte
;
class
word
{
uint64_t
content
KJ_UNUSED_MEMBER
;
KJ_DISALLOW_COPY
(
word
);
public
:
word
()
=
default
;
};
// word is an opaque type with size of 64 bits. This type is useful only to make pointer
// arithmetic clearer. Since the contents are private, the only way to access them is to first
// reinterpret_cast to some other pointer type.
//
// Copying is disallowed because you should always use memcpy(). Otherwise, you may run afoul of
// aliasing rules.
//
// A pointer of type word* should always be word-aligned even if won't actually be dereferenced as
// that type.
class
word
{
// word is an opaque type with size of 64 bits. This type is useful only to make pointer
// arithmetic clearer. Since the contents are private, the only way to access them is to first
// reinterpret_cast to some other pointer type.
//
// Copying is disallowed because you should always use memcpy(). Otherwise, you may run afoul of
// aliasing rules.
//
// A pointer of type word* should always be word-aligned even if won't actually be dereferenced
// as that type.
public
:
word
()
=
default
;
private
:
uint64_t
content
KJ_UNUSED_MEMBER
;
#if __GNUC__ < 8 || __clang__
// GCC 8's -Wclass-memaccess complains whenever we try to memcpy() a `word` if we've disallowed
// the copy constructor. We don't want to disable the warning becaues it's a useful warning and
// we'd have to disable it for all applications that include this header. Instead we allow `word`
// to be copyable on GCC.
KJ_DISALLOW_COPY
(
word
);
#endif
};
static_assert
(
sizeof
(
byte
)
==
1
,
"uint8_t is not one byte?"
);
static_assert
(
sizeof
(
word
)
==
8
,
"uint64_t is not 8 bytes?"
);
...
...
c++/src/capnp/layout.c++
View file @
7db342c0
...
...
@@ -72,6 +72,16 @@ namespace _ { // private
// =======================================================================================
#if __GNUC__ >= 8 && !__clang__
// GCC 8 introduced a warning which complains whenever we try to memset() or memcpy() a
// WirePointer, becaues we deleted the regular copy constructor / assignment operator. Weirdly, if
// I remove those deletions, GCC *still* complains that WirePointer is non-trivial. I don't
// understand why -- maybe because WireValue has private members? We don't want to make WireValue's
// member public, but memset() and memcpy() on it are certainly valid and desirable, so we'll just
// have to disable the warning I guess.
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
struct
WirePointer
{
// A pointer, in exactly the format in which it appears on the wire.
...
...
c++/src/kj/async-inl.h
View file @
7db342c0
...
...
@@ -249,6 +249,13 @@ private:
// -------------------------------------------------------------------
#if __GNUC__ >= 8 && !__clang__
// GCC 8's class-memaccess warning rightly does not like the memcpy()'s below, but there's no
// "legal" way for us to extract the contetn of a PTMF so too bad.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
class
PtmfHelper
{
// This class is a private helper for GetFunctorStartAddress. The class represents the internal
// representation of a pointer-to-member-function.
...
...
@@ -310,6 +317,10 @@ class PtmfHelper {
#undef BODY
};
#if __GNUC__ >= 8 && !__clang__
#pragma GCC diagnostic pop
#endif
template
<
typename
...
ParamTypes
>
struct
GetFunctorStartAddress
{
// Given a functor (any object defining operator()), return the start address of the function,
...
...
c++/src/kj/async-io-unix.c++
View file @
7db342c0
...
...
@@ -906,7 +906,6 @@ Promise<Array<SocketAddress>> SocketAddress::lookupHost(
}
SocketAddress
addr
;
memset
(
&
addr
,
0
,
sizeof
(
addr
));
// mollify valgrind
if
(
params
.
host
==
"*"
)
{
// Set up a wildcard SocketAddress. Only use the port number returned by getaddrinfo().
addr
.
wildcard
=
true
;
...
...
c++/src/kj/encoding.c++
View file @
7db342c0
...
...
@@ -249,6 +249,13 @@ EncodingResult<String> decodeUtf32(ArrayPtr<const char32_t> utf16) {
namespace
{
#if __GNUC__ >= 8 && !__clang__
// GCC 8's new class-memaccess warning rightly dislikes the following hacks, but we're really sure
// we want to allow them so disable the warning.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
template
<
typename
To
,
typename
From
>
Array
<
To
>
coerceTo
(
Array
<
From
>&&
array
)
{
static_assert
(
sizeof
(
To
)
==
sizeof
(
From
),
"incompatible coercion"
);
...
...
@@ -269,6 +276,10 @@ EncodingResult<Array<To>> coerceTo(EncodingResult<Array<From>>&& result) {
return
{
coerceTo
<
To
>
(
Array
<
From
>
(
kj
::
mv
(
result
))),
result
.
hadErrors
};
}
#if __GNUC__ >= 8 && !__clang__
#pragma GCC diagnostic pop
#endif
template
<
size_t
s
>
struct
WideConverter
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment