Subject: toolchain/33005: gnu/dist/gcc/gcc/cp/decl.c has bad code
To: None <toolchain-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <cagney@gnu.org>
List: netbsd-bugs
Date: 03/05/2006 20:50:01
>Number:         33005
>Category:       toolchain
>Synopsis:       gnu/dist/gcc/gcc/cp/decl.c has bad code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 05 20:50:01 +0000 2006
>Originator:     cagney
>Release:        head
>Organization:
>Environment:
gcc 4.1
>Description:
This isn't legal C:

   (cond ? a : b) = c;

the HEAD compiler contains such code
>How-To-Repeat:

>Fix:
Not pretty but it appears to work :-)

Index: gnu/dist/gcc/gcc/cp/decl.c
===================================================================
RCS file: /cvsroot/src/gnu/dist/gcc/gcc/cp/decl.c,v
retrieving revision 1.1.1.4
diff -p -u -r1.1.1.4 decl.c
--- gnu/dist/gcc/gcc/cp/decl.c  10 Feb 2004 12:09:50 -0000      1.1.1.4
+++ gnu/dist/gcc/gcc/cp/decl.c  5 Mar 2006 20:47:12 -0000
@@ -672,10 +672,17 @@ struct cp_binding_level GTY(())

 /* The binding level currently in effect.  */

+#if 0
 #define current_binding_level                  \
   (cfun && cp_function_chain->bindings         \
    ? cp_function_chain->bindings               \
    : scope_chain->bindings)
+#else
+#define current_binding_level                  \
+  (*(cfun && cp_function_chain->bindings       \
+     ? &cp_function_chain->bindings            \
+     : &scope_chain->bindings))
+#endif

 /* The binding level of the current class, if any.  */