You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2018/04/01 18:10:00 UTC

[jira] [Commented] (AVRO-2081) Compilation fails with clang

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

ASF subversion and git services commented on AVRO-2081:
-------------------------------------------------------

Commit 8466975290773f5e0d19a16d2c36c05d64ea5134 in avro's branch refs/heads/master from [~pnayak]
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=8466975 ]

Fix compilation error caused due to vector<bool> specialization.

The codec_traits<> specialization of vector<T> assumes that there is a
codec_traits<T> specialization of type T. It dereferences a
const_iterator pointing to an element in vector<T> to get a
const_reference and then encodes/decodes that element using the
codec_traits<T> specialization.

This works readily with g++ (gcc) where vector<bool>::const_reference is
same as bool and we have a codec_traits<bool> specialization. However,
in the case of c++ (clang) this vector<bool>::const_reference != bool.
So there will be missing specialization for
codec_traits<vector<bool>::const_reference>.

Adding the above specialization will fix the clang but will create a
second definition in case of g++ and violate ODR and hence compilation
failure.

This change provides a specialization of
codec_traits<vector<bool>::const_reference> if it doesn't already
exist. This should make it work for both c++ and g++. I've also added a
test case to cover this, so we can catch it if future changes in
implementation breaks it or for testing with other implementations.

Fixes AVRO-2081


> Compilation fails with clang
> ----------------------------
>
>                 Key: AVRO-2081
>                 URL: https://issues.apache.org/jira/browse/AVRO-2081
>             Project: Avro
>          Issue Type: Bug
>          Components: c++
>    Affects Versions: 1.8.2
>         Environment: FreeBSD, clang++ (3.8.0)
>            Reporter: Purushotham Nayak
>            Assignee: Purushotham Nayak
>            Priority: Minor
>             Fix For: 1.9.0
>
>         Attachments: AVRO-2081.patch
>
>
> Building on {{clang}}  fails with the error below. This is because of the {{vector<bool>}} specialization. We need a {{codec_traits}} specialization for {{vector<bool>::const_reference}}.
> {code}
> avro/lang/c++/api/Specific.hh:321:22: error: no member named 'encode' in 'avro::codec_traits<std::__1::__bit_const_reference<std::__1::vector<bool, std::__1::allocator<bool> > > >'
>     codec_traits<T>::encode(e, t);
>     ~~~~~~~~~~~~~~~~~^
> avro/lang/c++/api/Specific.hh:235:23: note: in instantiation of function template specialization 'avro::encode<std::__1::__bit_const_reference<std::__1::vector<bool, std::__1::allocator<bool> > > >' requested here
>                 avro::encode(e, *it);
>                       ^
> avro/lang/c++/api/Specific.hh:321:22: note: in instantiation of member function 'avro::codec_traits<std::__1::vector<bool, std::__1::allocator<bool> > >::encode' requested here
>     codec_traits<T>::encode(e, t);
>                      ^
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)