diff mbox

C++ PATCH to change default dialect to C++14

Message ID 559430F3.2040109@redhat.com
State New
Headers show

Commit Message

Jason Merrill July 1, 2015, 6:26 p.m. UTC
I've been threatening to do this for a couple of months, and now that 
the regressions are under control I think it's time.  This patch changes 
the default C++ dialect to C++14.

Tested x86_64-pc-linux-gnu, applying to trunk.

Comments

Marek Polacek July 1, 2015, 6:38 p.m. UTC | #1
On Wed, Jul 01, 2015 at 02:26:59PM -0400, Jason Merrill wrote:
> I've been threatening to do this for a couple of months, and now that the
> regressions are under control I think it's time.  This patch changes the
> default C++ dialect to C++14.

Great!

It seems that our cppopts.texi is very outdated wrt C++ standards...

	Marek
Jim Wilson July 2, 2015, 4:10 a.m. UTC | #2
On 07/01/2015 11:26 AM, Jason Merrill wrote:
> I've been threatening to do this for a couple of months, and now that
> the regressions are under control I think it's time.  This patch changes
> the default C++ dialect to C++14.
> 
> Tested x86_64-pc-linux-gnu, applying to trunk.

This causes a build failure on Ubuntu 14.04 LTS (Trusty) for x86_64 and
armhf and probably others.  All of the graphite*.c files fail with
/home/wilson/FOSS/GCC/X-palantir/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include/cstddef:51:11:
error: ‘::max_align_t’ has not been declared
   using ::max_align_t;

This is a known gmp problem, documented in PR56019 and in
    https://gcc.gnu.org/gcc-4.9/porting_to.html
near the bottom where it discusses cstddef.h changes.  Except the
cstddef.h changes didn't matter until C++11 or later became the default.

This is apparently fixed in gmp 6.0.0.  I haven't had a chance to try
that yet.  The prereqs section on doc/install.texi says we need gmp
4.3.2 or later, so it appears that this needs to change too.

This is maybe only a problem if you have the isl libraries installed.

Jim
Jason Merrill July 2, 2015, 5:21 a.m. UTC | #3
On 07/02/2015 12:10 AM, Jim Wilson wrote:
> This is a known gmp problem, documented in PR56019 and in
>      https://gcc.gnu.org/gcc-4.9/porting_to.html
> near the bottom where it discusses cstddef.h changes.

This document also says that "A workaround until libraries get updated 
is to include <cstddef> or <stddef.h> before any headers from that library."

Can you try modifying the graphite* files accordingly?

Thanks,
Jason
Marc Glisse July 2, 2015, 6:18 a.m. UTC | #4
On Thu, 2 Jul 2015, Jason Merrill wrote:

> On 07/02/2015 12:10 AM, Jim Wilson wrote:
>> This is a known gmp problem, documented in PR56019 and in
>>      https://gcc.gnu.org/gcc-4.9/porting_to.html
>> near the bottom where it discusses cstddef.h changes.
>
> This document also says that "A workaround until libraries get updated is to 
> include <cstddef> or <stddef.h> before any headers from that library."
>
> Can you try modifying the graphite* files accordingly?

See also

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65988#c1

system.h looks like the right way to include gmp.h in gcc, currently.
Richard Biener July 2, 2015, 1:05 p.m. UTC | #5
On Thu, Jul 2, 2015 at 8:18 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Thu, 2 Jul 2015, Jason Merrill wrote:
>
>> On 07/02/2015 12:10 AM, Jim Wilson wrote:
>>>
>>> This is a known gmp problem, documented in PR56019 and in
>>>      https://gcc.gnu.org/gcc-4.9/porting_to.html
>>> near the bottom where it discusses cstddef.h changes.
>>
>>
>> This document also says that "A workaround until libraries get updated is
>> to include <cstddef> or <stddef.h> before any headers from that library."
>>
>> Can you try modifying the graphite* files accordingly?
>
>
> See also
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65988#c1
>
> system.h looks like the right way to include gmp.h in gcc, currently.

Yeah, I _think_ the fix is to move the isl includes below the system.h
include.

Richard.

> --
> Marc Glisse
Richard Biener July 2, 2015, 1:08 p.m. UTC | #6
On Thu, Jul 2, 2015 at 3:05 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Thu, Jul 2, 2015 at 8:18 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
>> On Thu, 2 Jul 2015, Jason Merrill wrote:
>>
>>> On 07/02/2015 12:10 AM, Jim Wilson wrote:
>>>>
>>>> This is a known gmp problem, documented in PR56019 and in
>>>>      https://gcc.gnu.org/gcc-4.9/porting_to.html
>>>> near the bottom where it discusses cstddef.h changes.
>>>
>>>
>>> This document also says that "A workaround until libraries get updated is
>>> to include <cstddef> or <stddef.h> before any headers from that library."
>>>
>>> Can you try modifying the graphite* files accordingly?
>>
>>
>> See also
>>
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65988#c1
>>
>> system.h looks like the right way to include gmp.h in gcc, currently.
>
> Yeah, I _think_ the fix is to move the isl includes below the system.h
> include.

And it should only affect the files including isl/val_gmp.h which includes
gmp.h.

> Richard.
>
>> --
>> Marc Glisse
Jim Wilson July 2, 2015, 3:53 p.m. UTC | #7
On Thu, Jul 2, 2015 at 6:08 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Thu, Jul 2, 2015 at 3:05 PM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> Yeah, I _think_ the fix is to move the isl includes below the system.h
>> include.

I tried this, and got a conflict for pretty much every macro defined
by ctype.h, e.g.

/usr/include/c++/4.8/bits/locale_facets.h:240:53: error: macro
"toupper" passed 2 arguments, but takes just 1
       toupper(char_type *__lo, const char_type* __hi) const

system.h includes safe-ctype.h which does
#include <ctype.h>
...
#undef toupper
#define toupper(c) do_not_use_toupper_with_safe_ctype

isl/int.h includes iostream which includes other header files that
want to define ctype like functions and we get a conflict.  I see that
<ctype.h> doesn't define any macros when __cplusplus is defined, but
if we disable the macro redefines in safe-ctype.h, it isn't very safe
anymore.  This is probably why the isl headers were deliberately
included before system.h when the ISL support was first added.

Jim
H.J. Lu July 10, 2015, 11:27 a.m. UTC | #8
On Wed, Jul 1, 2015 at 11:26 AM, Jason Merrill <jason@redhat.com> wrote:
> I've been threatening to do this for a couple of months, and now that the
> regressions are under control I think it's time.  This patch changes the
> default C++ dialect to C++14.
>
> Tested x86_64-pc-linux-gnu, applying to trunk.

This caused:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66829
diff mbox

Patch

commit 6f2b3941ffb3734cecc05507dd8ed46f6a6d4f2d
Author: Jason Merrill <jason@redhat.com>
Date:   Fri May 8 17:02:05 2015 -0500

    gcc/c-family/
    	* c-opts.c (c_common_post_options): Default to C++14.
    gcc/testsuite/
    	* lib/target-supports.exp (cxx_default): Set to C++14.

diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 195045e..80481c3 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -889,9 +889,9 @@  c_common_post_options (const char **pfilename)
   if (flag_abi_version == 0)
     flag_abi_version = 10;
 
-  /* Set C++ standard to C++98 if not specified on the command line.  */
+  /* Set C++ standard to C++14 if not specified on the command line.  */
   if (c_dialect_cxx () && cxx_dialect == cxx_unset)
-    set_std_cxx98 (/*ISO*/false);
+    set_std_cxx14 (/*ISO*/false);
 
   if (cxx_dialect >= cxx11)
     {
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index fc05e84..bf512e9 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -5935,7 +5935,7 @@  proc check_effective_target_c++ { } {
  return 0
 }
 
-set cxx_default "c++98"
+set cxx_default "c++14"
 # Check whether the current active language standard supports the features
 # of C++11/C++14 by checking for the presence of one of the -std flags.
 # This assumes that the default for the compiler is $cxx_default, and that