1 |
Am Donnerstag, 19. Dezember 2013, 16:23:08 schrieb Jan Kundrát: |
2 |
> On Thursday, 19 December 2013 16:00:13 CEST, Ian Stakenvicius wrote: |
3 |
> > A change in profiles? 14.0/* adds that to the default CXXFLAGS in |
4 |
> > base, new stage3's etc are all rolled with this. We recommend |
5 |
> > migration to 14.0 profile and have a check somewhere about |
6 |
> > "-std=c++11" missing from CXXFLAGS in case it's overridden in |
7 |
> > make.conf, so users put it in place? |
8 |
> |
9 |
> Before you invest any more time in this, please understand that C++98 and |
10 |
> C++11 are source-incompatible. There is no way to expect that a package |
11 |
> builds fine when you throw -std=c++11 on it. And even if you patched them |
12 |
> all, you are breaking an unknown number of 3rd party software over which |
13 |
> you have exactly zero control. |
14 |
|
15 |
No. If you do something against the standard that is working due to lack of |
16 |
control when compiling with -std=c++98, then your source code is severly |
17 |
broken. Most developers will use C++03 (plus tr1) anyway, won't they? |
18 |
|
19 |
And no, the languages are _not_ "source-incompatible". That would be a |
20 |
scandal! |
21 |
|
22 |
But if you have your C++98/03 code, and do what most developers do and let |
23 |
your console be flooded with warnings you ignore, you must not be surprised, |
24 |
if the compilation fails when you decide to throw |
25 |
"-std=c++11 -Wall -Wextra -Wpedantic -fsanitize=address -fsanitize=thread" |
26 |
with gcc 4.8.2 at it. |
27 |
|
28 |
There is absolutely no reason to expect a compilation to fail with C++11, if |
29 |
it went well with C++03 and "-Wall -Wextra -pedantic". |
30 |
|
31 |
If you try to outsmart your compiler, it will get it's revenge very soon and |
32 |
very hard. |
33 |
|
34 |
And according to [1] it goes even further: |
35 |
Quote: |
36 |
> If you use C++11 then in general you can combine C++11 code built with GCC |
37 |
> 4.X and C++03 code built with any GCC, but there is not the same guarantee |
38 |
> that you can combine with C++11 code built with GCC 4.Y or GCC 4.Z, because |
39 |
> the C++11 features are not all stable yet (e.g. for GCC 4.9 I'm about to add |
40 |
> a new virtual function to a base class in <future>.) This is why C++11 |
41 |
> support is still labelled "experimental", because it would be worse to claim |
42 |
> it's stable and then have to break the ABI. |
43 |
|
44 |
So basically C++11 <-> C++03 is no problem at all (unless you *export* certain |
45 |
symbols [2]), but combining C++11 from different gcc versions is nowhere |
46 |
guaranteed to work. |
47 |
|
48 |
Cheers |
49 |
|
50 |
Sven |
51 |
|
52 |
|
53 |
[1] : https://lwn.net/Articles/552831/ |
54 |
[2] : http://gcc.gnu.org/wiki/Cxx11AbiCompatibility |