public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33226] New: class name permitted in enum
@ 2007-08-29 12:12 asteinarson at gmail dot com
2007-08-29 17:09 ` [Bug c++/33226] " pinskia at gcc dot gnu dot org
2007-09-08 15:27 ` bangerth at dealii dot org
0 siblings, 2 replies; 3+ messages in thread
From: asteinarson at gmail dot com @ 2007-08-29 12:12 UTC (permalink / raw)
To: gcc-bugs
If an identifier given inside an enum is the same as an existing class
the compiler still accepts it:
<<< code <<<
class MyClass { };
MyClass g_my_class; // An instance
enum { Mode1, MyClass }; // We could have error already here
MyClass g_my_class2; // Compiler gives error here
<<< endcode <<<
For functions the desired behaviour is there:
<<< code <<<
int MyFunc() { return 0; }
enum { Mode1, MyFunc }; // Compiler objects here
<<< endcode <<<
Inside an enum it is very seldom the purpose to overwrite a class or template
in the global namespace. It is accidental, so an early error from the compiler
would be good.
Also template names can be overwritten inside enums.
Regards
Arne Steinarson
--
Summary: class name permitted in enum
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: asteinarson at gmail dot com
GCC build triplet: Linux, Ubuntu 7.04
GCC host triplet: Linux, Ubuntu 7.04
GCC target triplet: Linux, Ubuntu 7.04
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33226
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/33226] class name permitted in enum
2007-08-29 12:12 [Bug c++/33226] New: class name permitted in enum asteinarson at gmail dot com
@ 2007-08-29 17:09 ` pinskia at gcc dot gnu dot org
2007-09-08 15:27 ` bangerth at dealii dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-08-29 17:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-08-29 17:09 -------
I have to look this up but I think this code is valid.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33226
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/33226] class name permitted in enum
2007-08-29 12:12 [Bug c++/33226] New: class name permitted in enum asteinarson at gmail dot com
2007-08-29 17:09 ` [Bug c++/33226] " pinskia at gcc dot gnu dot org
@ 2007-09-08 15:27 ` bangerth at dealii dot org
1 sibling, 0 replies; 3+ messages in thread
From: bangerth at dealii dot org @ 2007-09-08 15:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from bangerth at dealii dot org 2007-09-08 15:27 -------
Yes, this is allowed.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33226
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-09-08 15:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-29 12:12 [Bug c++/33226] New: class name permitted in enum asteinarson at gmail dot com
2007-08-29 17:09 ` [Bug c++/33226] " pinskia at gcc dot gnu dot org
2007-09-08 15:27 ` bangerth at dealii dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).