[ https://issues.apache.org/jira/browse/AVRO-2598?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Tzvetanov Grigorov resolved AVRO-2598. --------------------------------------------- Fix Version/s: 1.12.0 Resolution: Fixed > C++ standard of library implies C++ standard of projects using Avro > ------------------------------------------------------------------- > > Key: AVRO-2598 > URL: https://issues.apache.org/jira/browse/AVRO-2598 > Project: Apache Avro > Issue Type: Bug > Components: c++ > Affects Versions: 1.9.0, 1.9.1 > Reporter: Marcel Pfütze > Priority: Major > Fix For: 1.12.0 > > > SInce Avro 1.9.0 there is an if macro in a lot of headers that uses the > current C++ standard. > If you build the library from source and use it in another project with a > different C++ standard this can lead to segfaults. > Example of macro: > {code:c++} > template<typename T> T& GenericDatum::value() { > return (type_ == AVRO_UNION) ? > #if __cplusplus >= 201703L > std::any_cast<GenericUnion>(&value_)->datum().value<T>() : > *std::any_cast<T>(&value_); > #else > boost::any_cast<GenericUnion>(&value_)->datum().value<T>() : > *boost::any_cast<T>(&value_); > #endif > {code} > In our case we build the library from source (which uses the c+11 by default) > and used it in a project using C+17. There's very little indication to the > user why the crash happens. > My proposals: > * Move implementation from header to source file so that the used standard > is decided at build time. > * Use the [CMAKE_CXX_STANDARD > |https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html] > functionality provided by cmake to set the standard. In this way the standard > can also easily set when building the code without actually manipulating the > CMakeLists.txt file. Of course the --std=c++11 > [here|https://github.com/apache/avro/blob/89218262cde62e98fcb3778b86cd3f03056c54f3/lang/c%2B%2B/CMakeLists.txt#L55] > can be removed. -- This message was sent by Atlassian Jira (v8.20.10#820010)