Gentoo Archives: gentoo-dev

From: Georg Rudoy <0xd34df00d@×××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] How to support C++11 in libraries?
Date: Fri, 20 Dec 2013 12:54:28
Message-Id: CAGbUWSKjGS8JfFEJ7HQQ0GxLXV7qGtn3ioPhF0a3=bFtUEC8Wg@mail.gmail.com
In Reply to: Re: [gentoo-dev] How to support C++11 in libraries? by "Jan Kundrát"
1 2013/12/20 Jan Kundrát <jkt@g.o>:
2 > On Friday, 20 December 2013 12:56:43 CEST, Sven Eden wrote:
3 >>
4 >> And no, the languages are _not_ "source-incompatible". That would be a
5 >> scandal!
6 >
7 >
8 > You might argue about this, but that doesn't change these facts. This is
9 > absolutely valid C++98 program:
10 >
11 > jkt@svist ~ $ cat foo.cpp int main() {
12 > auto int foo;
13 > return 0;
14 > }
15 > jkt@svist ~ $ g++ -std=c++98 -pedantic foo.cpp
16 > jkt@svist ~ $ echo $?
17 > 0
18 >
19 > ...which will *not* build under the C++11 mode:
20 >
21 > jkt@svist ~ $ g++ -std=c++0x foo.cpp
22 > foo.cpp: In function ‘int main()’:
23 > foo.cpp:2:14: error: two or more data types in declaration of ‘foo’
24 >
25 > Yes, -Wc++0x-compat warns about this, yes, it's included in -Wall, but it
26 > does not change the fact that there *is* code out there which does conform
27 > to C++98 standard, does *not* try to "outsmart the compiler", and which will
28 > not build in the C++11 mode. Do we really have to be having this discussion?
29
30 The C++ Committee considered this exact case in relation to the new
31 meaning of `auto` and decided that such code doesn't really exist in
32 the wild. You won't hit auto-related issues in almost all packages in
33 Portage I guess.
34
35 There are more obscure cases of incompatibility though, with more
36 obscure error messages, like with autogenerated move ctors and the
37 likes. I've hitted it myself a couple of times in more or less complex
38 template code, but can't think of an example off the top of my head
39 unfortunately.
40
41 --
42 Georg Rudoy
43 LeechCraft — http://leechcraft.org