eggs-cpp / variant

Eggs.Variant is a C++11/14/17 generic, type-safe, discriminated union.
http://eggs-cpp.github.io/variant/
Boost Software License 1.0
137 stars 27 forks source link

Does not compile with GCC 4.9 #13

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hi!

In my Debian Sid machine, GCC 4.9, eggs::variant fails to compile. I get the following error:

../third-party/eggs-variant/include/eggs/variant/detail/storage.hpp:321:16: error: ‘std::is_trivially_copyable’ has not been declared
     using std::is_trivially_copyable;
                ^

The problem is, I reckon, that __GLIBCXX__ == 20150826, and is_trivially_copyable is detected via the following preprocessor directives:

#ifndef EGGS_CXX11_STD_HAS_IS_TRIVIALLY_COPYABLE
#  if defined(__GLIBCXX__) && __GLIBCXX__ < 20150422
#    define EGGS_CXX11_STD_HAS_IS_TRIVIALLY_COPYABLE 0
...

Apparently, __GLIBCXX__ is not monotonic, i.e. minor bugfix upgrades for older versions still get bumped to current date. It's unclear to me what the right solution is here...

Further information:

$ g++-4.9 --version
g++-4.9 (Debian 4.9.3-4) 4.9.3
$ apt show libstdc++-4.9-dev
Package: libstdc++-4.9-dev
Source: gcc-4.9
Version: 4.9.3-4
Installed-Size: 12.4 MB
Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org>

Thanks a lot!

K-ballo commented 9 years ago

Hi, and thanks for your report!

Apparently, GLIBCXX is not monotonic, i.e. minor bugfix upgrades for older versions still get bumped to current date.

Indeed, the only reliable way to detect libstdc++ features is to craft and run feature tests during configuration stage (but the library doesn't have one as it is header only).

It's unclear to me what the right solution is here...

Eggs.Variant expects a standard conforming C++11 compiler. If you don't provide one, it will make its educated guesses and try to adapt. You can overrule any of those guesses, right or wrong, by setting the corresponding config macro, so in this case you could just add -DEGGS_CXX11_STD_HAS_IS_TRIVIALLY_COPYABLE=0.

I will most likely simply drop trivially-copyable support for gcc for another round.

ghost commented 9 years ago

I'm happy with the workaround. Thanks!

K-ballo commented 9 years ago

Addressed by af95784b6485e4739cef9bdbba3ade216645f464