[Bug c++/69023] bitset whose name is used in constant-expression rejected

2015-12-23 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69023

--- Comment #5 from Martin Sebor  ---
Author: msebor
Date: Wed Dec 23 21:52:50 2015
New Revision: 231938

URL: https://gcc.gnu.org/viewcvs?rev=231938&root=gcc&view=rev
Log:
PR c++/69023 - bitset whose name is used in constant-expression rejected
* g++.dg/lookup/name-clash11.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/lookup/name-clash11.C
Modified:
trunk/gcc/testsuite/ChangeLog

[Bug c++/69023] bitset whose name is used in constant-expression rejected

2015-12-23 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69023

Martin Sebor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #4 from Martin Sebor  ---
Thanks for the reference!  I now see it quoted in the code as well.   (I should
have looked it up before opening the bug.)  I'll close it as invalid, though
perhaps adding a test case might be useful since I don't see this case covered
in the test suite.  Let me submit one.

[Bug c++/69023] bitset whose name is used in constant-expression rejected

2015-12-23 Thread rs2740 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69023

TC  changed:

   What|Removed |Added

 CC||rs2740 at gmail dot com

--- Comment #3 from TC  ---
[basic.scope.class]/1, item 2:

A name N used in a class S shall refer to the same declaration in its context
and when re-evaluated in the completed scope of S. No diagnostic is required
for a violation of this rule.

[Bug c++/69023] bitset whose name is used in constant-expression rejected

2015-12-22 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69023

--- Comment #2 from Martin Sebor  ---
I'm not sure.  I did read the relevant text in the C++ and C standards and I
can't say I see a clear answer.  But then it rarely seems to be in these corner
cases.

GCC (in C mode) accepts the code.  All other C and C++ compilers I have access
to (about half a dozen) do as well.  The one interesting thing I noticed that
the EDG front end issues the following warnings in C89 and C++ modes but not in
C99 and later.

"b.c", line 4: warning: reference to local variable of enclosing function is
  not allowed
  struct { int  : sizeof x; } b0; (void)&b0;
 ^

"b.c", line 5: warning: reference to local variable of enclosing function is
  not allowed
  struct { int x: sizeof x; } b1; (void)&b1;
 ^

[Bug c++/69023] bitset whose name is used in constant-expression rejected

2015-12-22 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69023

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||diagnostic

--- Comment #1 from Andrew Pinski  ---
I think GCC is correct with its error message for b1 even if it does not do it
also for b2.  The meaning of x does change after the struct is finalized.

Note this kind of diagnostic is not required to happen.  That is the standard
says the code is invalid but no diagnostic is required.  This is one case where
the two compilers can disagree but both be correct even though the one of them
rejects the code.