[ 
https://issues.apache.org/jira/browse/KUDU-2094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16122770#comment-16122770
 ] 

Tim Armstrong commented on KUDU-2094:
-------------------------------------

Yeah I believe the alignment requirement comes from the embedded Cell. My 
understanding is that C++ new pre-C++17 is not aware of alignment requirements: 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0035r4.html

{code}
[58 to run/1 running/37 finished] Building CXX object 
be/src/kudu/util/CMakeFiles/kudu_util.dir/flags.cc.o
FAILED: ccache 
/home/tarmstrong/Impala/incubator-impala-gcc71/toolchain/gcc-7.1.0/bin/g++   
-DHAVE_INTTYPES_H -DHAVE_NETDB_H -DHAVE_NETINET_IN_H -DKUDU_HEADERS_NO_STUBS 
-DKUDUc
In file included from be/src/kudu/util/flags.cc:39:0:
be/src/kudu/util/metrics.h: In member function ‘scoped_refptr<kudu::Counter> 
kudu::MetricEntity::FindOrCreateCounter(const kudu::CounterPrototype*)’:
be/src/kudu/util/metrics.h:1031:26: error: ‘new’ of type ‘kudu::Counter’ with 
extended alignment 64 [-Werror=aligned-new=]
     m = new Counter(proto);                ^
{code}

We generally inherit from AlignedNew to deal with this case: 
https://github.com/apache/incubator-impala/blob/9270346825b0bbc7708d458be076d7c26038edfc/be/src/util/aligned-new.h

> GCC 7.1 complains about alignment of Counter
> --------------------------------------------
>
>                 Key: KUDU-2094
>                 URL: https://issues.apache.org/jira/browse/KUDU-2094
>             Project: Kudu
>          Issue Type: Bug
>            Reporter: Tim Armstrong
>            Priority: Minor
>
> I found this when building the kudu/util subtree in Impala with gcc 7.1.
> In a few places, e.g. metrics.h, the compiler complains that the alignment 
> required by Counter is less than the alignment guaranteed by new.
> {code}
>     m = new Counter(proto);
> {code}
> I worked around this by setting -faligned-new, which was added recently to 
> GCC and is enabled by default with C++17. The setting ensures that new 
> allocates memory with the alignment required by the data type.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to