Hi,

as described in the PR 69865, some bits are not properly initialized when the 
-std=gnu++14
option is not present on the command line.  That includes the options 
-trigraphs and
-fno-extended-identifiers which are effectively overridden by the default 
handling.
Also the define __GNUC_GNU_INLINE__ vs. __GNUC_STDC_INLINE__ is differently
defined if -std=gnu++14 is given on the command line than when the default 
takes effect,
which is also supposed to be gnu++14 too.

While I think that we should probably not define __GNUC_GNU_INLINE__ at all for 
C++,
because it is meaningless, I am warned that this could break (already broken) 
header files.
I think the safest thing would be to unconditionally define __GNUC_GNU_INLINE__ 
for C++
and not use flag_isoc99 for that decision which is true for c++11 and above, 
but was undefined
previously when the -std option was not used on the command line.

Unfortunately this specific bug, cannot be tested in the test suite, especially 
the -trigraphs
have already test cases under c-c++common, which should have been failing all 
the time,
but, unfortunately the test suite always adds -std=xxx for c++ tests.  So I 
would like to make
an exception here to the general rule that every patch has to add a test case 
of its own.

I would like this patch to be considered for gcc-6 because the undefined state 
of the predefined
GNUC-define worries me a bit.


Boot-strapped and regression tested on x86_64-pc-linux-gnu.
OK for trunk?


Thanks
Bernd.
2016-02-19  Bernd Edlinger  <bernd.edlin...@hotmail.de>

        PR c++/69865
        * c-opts.c (c_common_post_options): Set flag_gnu89_inline for C++.
        Move call to set_std_cxx14 from here...
        (c_common_init_options): ...to here.
        (set_std_cxx98): Initialize flag_isoc94 and flag_isoc99.
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c	(revision 233531)
+++ gcc/c-family/c-opts.c	(working copy)
@@ -246,6 +246,10 @@ c_common_init_options (unsigned int decoded_option
 	  }
     }
 
+  /* Set C++ standard to C++14 if not specified on the command line.  */
+  if (c_dialect_cxx ())
+    set_std_cxx14 (/*ISO*/false);
+
   global_dc->colorize_source_p = true;
 }
 
@@ -786,7 +790,7 @@ c_common_post_options (const char **pfilename)
   /* By default we use C99 inline semantics in GNU99 or C99 mode.  C99
      inline semantics are not supported in GNU89 or C89 mode.  */
   if (flag_gnu89_inline == -1)
-    flag_gnu89_inline = !flag_isoc99;
+    flag_gnu89_inline = c_dialect_cxx () || !flag_isoc99;
   else if (!flag_gnu89_inline && !flag_isoc99)
     error ("-fno-gnu89-inline is only supported in GNU99 or C99 mode");
 
@@ -802,10 +806,6 @@ c_common_post_options (const char **pfilename)
       && flag_no_builtin)
     flag_tree_loop_distribute_patterns = 0;
 
-  /* Set C++ standard to C++14 if not specified on the command line.  */
-  if (c_dialect_cxx () && cxx_dialect == cxx_unset)
-    set_std_cxx14 (/*ISO*/false);
-
   /* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
      It is never enabled in C++, as the minimum limit is not normative
      in that standard.  */
@@ -1519,6 +1519,8 @@ set_std_cxx98 (int iso)
   flag_no_gnu_keywords = iso;
   flag_no_nonansi_builtin = iso;
   flag_iso = iso;
+  flag_isoc94 = 0;
+  flag_isoc99 = 0;
   cxx_dialect = cxx98;
   lang_hooks.name = "GNU C++98";
 }

Reply via email to