public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type'
@ 2005-03-22 15:45 caolanm at redhat dot com
2005-03-22 15:46 ` [Bug c++/20589] " caolanm at redhat dot com
` (16 more replies)
0 siblings, 17 replies; 19+ messages in thread
From: caolanm at redhat dot com @ 2005-03-22 15:45 UTC (permalink / raw)
To: gcc-bugs
g++ -c the attached example with 4.0 gives the above error. Is this expected
behaviour ?
--
Summary: error: '<anonymous enum>' is/uses anonymous type'
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: caolanm at redhat dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
@ 2005-03-22 15:46 ` caolanm at redhat dot com
2005-03-22 16:10 ` pinskia at gcc dot gnu dot org
` (15 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: caolanm at redhat dot com @ 2005-03-22 15:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From caolanm at redhat dot com 2005-03-22 15:46 -------
Created an attachment (id=8433)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8433&action=view)
example
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
2005-03-22 15:46 ` [Bug c++/20589] " caolanm at redhat dot com
@ 2005-03-22 16:10 ` pinskia at gcc dot gnu dot org
2005-03-22 16:16 ` mmitchel at gcc dot gnu dot org
` (14 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-22 16:10 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-22 16:09 -------
I think this is invalid code.
Mark I think you changed the front-end code to reject this, can you comment on validness of the code
attached in this bug?
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |mmitchel at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
2005-03-22 15:46 ` [Bug c++/20589] " caolanm at redhat dot com
2005-03-22 16:10 ` pinskia at gcc dot gnu dot org
@ 2005-03-22 16:16 ` mmitchel at gcc dot gnu dot org
2005-03-23 11:54 ` caolanm at redhat dot com
` (13 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-03-22 16:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2005-03-22 16:16 -------
Yes, this is invalid code, as the template parameters involve an anonymous type.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (2 preceding siblings ...)
2005-03-22 16:16 ` mmitchel at gcc dot gnu dot org
@ 2005-03-23 11:54 ` caolanm at redhat dot com
2005-03-23 16:57 ` pinskia at gcc dot gnu dot org
` (12 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: caolanm at redhat dot com @ 2005-03-23 11:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From caolanm at redhat dot com 2005-03-23 11:53 -------
The workaround is trivial. But I'm still confused as to what exactly causes gcc
to treat unnamed enums so much differently that named ones. It would be great if
I could get some clarity on this. I have a handful of cases like this in the
openoffice.org code base and OOo is reluctant to take the patches to fix unless
sure it's currently invalid.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (3 preceding siblings ...)
2005-03-23 11:54 ` caolanm at redhat dot com
@ 2005-03-23 16:57 ` pinskia at gcc dot gnu dot org
2005-03-23 18:53 ` bangerth at dealii dot org
` (11 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-23 16:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-23 16:57 -------
(In reply to comment #4)
> The workaround is trivial. But I'm still confused as to what exactly causes gcc
> to treat unnamed enums so much differently that named ones. It would be great if
> I could get some clarity on this. I have a handful of cases like this in the
> openoffice.org code base and OOo is reluctant to take the patches to fix unless
> sure it's currently invalid.
Because the standard treats them differently.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (4 preceding siblings ...)
2005-03-23 16:57 ` pinskia at gcc dot gnu dot org
@ 2005-03-23 18:53 ` bangerth at dealii dot org
2005-03-23 19:12 ` caolanm at redhat dot com
` (10 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: bangerth at dealii dot org @ 2005-03-23 18:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-03-23 18:53 -------
Intuitively, C++ treats unnamed enums differently than named ones, because
in templates the function/class name has to be mangled, and will contain
the name of the template arguments. If the template argument doesn't have
a name, then the compiler can't do its job, so the standard chose to
disallow unnamed enums as template arguments.
For more legalese, this is specified in section 14.3.1/2 of the standard,
which says:
2 A local type, a type with no linkage, an unnamed type or a type
compounded from any of these types shall not be used as a template-
argument for a template type-parameter. [Example: ...
Regards
Wolfgang
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (5 preceding siblings ...)
2005-03-23 18:53 ` bangerth at dealii dot org
@ 2005-03-23 19:12 ` caolanm at redhat dot com
2005-03-23 19:24 ` bangerth at dealii dot org
` (9 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: caolanm at redhat dot com @ 2005-03-23 19:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From caolanm at redhat dot com 2005-03-23 19:12 -------
Sounds reasonable, but it's not the case that the compiler should just silently
not consider anonymous enums as candidates for template argument matching ?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (6 preceding siblings ...)
2005-03-23 19:12 ` caolanm at redhat dot com
@ 2005-03-23 19:24 ` bangerth at dealii dot org
2005-03-23 19:28 ` mark at codesourcery dot com
` (8 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: bangerth at dealii dot org @ 2005-03-23 19:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-03-23 19:24 -------
That has been subject to discussion (i.e. whether the attempt to use an
unnamed enum as a template argument should just silently fail as a
substitution failure). However, it has been decided that this is a hard
error, not only a substitution failure.
I am presently not quite sure about the reasoning, and I believe that there
was a DR or something still pending. Mark, do you remember the details? I
think this came up in a different PR before...
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (7 preceding siblings ...)
2005-03-23 19:24 ` bangerth at dealii dot org
@ 2005-03-23 19:28 ` mark at codesourcery dot com
2005-03-23 21:56 ` bangerth at dealii dot org
` (7 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: mark at codesourcery dot com @ 2005-03-23 19:28 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mark at codesourcery dot com 2005-03-23 19:28 -------
Subject: Re: error: '<anonymous enum>' is/uses anonymous type'
bangerth at dealii dot org wrote:
> ------- Additional Comments From bangerth at dealii dot org 2005-03-23 19:24 -------
> That has been subject to discussion (i.e. whether the attempt to use an
> unnamed enum as a template argument should just silently fail as a
> substitution failure). However, it has been decided that this is a hard
> error, not only a substitution failure.
>
> I am presently not quite sure about the reasoning, and I believe that there
> was a DR or something still pending. Mark, do you remember the details? I
> think this came up in a different PR before...
It's swapped out of my brain, but there was another PR, and I did raise
the issue for Steve Adamczyk, to be added to the core issue list. The
basic point is that the SFINAE rules simply do not cover this case; they
precisely describe a set of situations in which no error should be
issued, and trying to use an anonymous type as a template parameter is
not among them.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (8 preceding siblings ...)
2005-03-23 19:28 ` mark at codesourcery dot com
@ 2005-03-23 21:56 ` bangerth at dealii dot org
2005-03-26 4:20 ` gdr at integrable-solutions dot net
` (6 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: bangerth at dealii dot org @ 2005-03-23 21:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-03-23 21:56 -------
Related PRs are: PR 19404, and in particular PR 17413. The latter is the one
I was thinking of.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (9 preceding siblings ...)
2005-03-23 21:56 ` bangerth at dealii dot org
@ 2005-03-26 4:20 ` gdr at integrable-solutions dot net
2005-03-26 22:53 ` bangerth at dealii dot org
` (5 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-03-26 4:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2005-03-26 04:20 -------
Subject: Re: error: '<anonymous enum>' is/uses anonymous type'
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| Intuitively, C++ treats unnamed enums differently than named ones, because
| in templates the function/class name has to be mangled, and will contain
| the name of the template arguments. If the template argument doesn't have
| a name, then the compiler can't do its job, so the standard chose to
| disallow unnamed enums as template arguments.
|
I know what the standard says, but the arguments used to make that rule
are bogus. Those are on my list of things to fix for C++0x.
If it were only mnagling, then the compiler can concoct a unique name
for manglaing purposes.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (10 preceding siblings ...)
2005-03-26 4:20 ` gdr at integrable-solutions dot net
@ 2005-03-26 22:53 ` bangerth at dealii dot org
2005-03-27 3:18 ` Gabriel Dos Reis
2005-03-27 3:18 ` gdr at integrable-solutions dot net
` (4 subsequent siblings)
16 siblings, 1 reply; 19+ messages in thread
From: bangerth at dealii dot org @ 2005-03-26 22:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-03-26 22:53 -------
Well, I wanted to give an "inuitive" reasoning.
On the other hand, how do you propose to make up a unique name if an
unnamed enum is used in two different translation units as a template
argument?
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-26 22:53 ` bangerth at dealii dot org
@ 2005-03-27 3:18 ` Gabriel Dos Reis
0 siblings, 0 replies; 19+ messages in thread
From: Gabriel Dos Reis @ 2005-03-27 3:18 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| Well, I wanted to give an "inuitive" reasoning.
I understood that; I just don't think they are conclusive :-)
| On the other hand, how do you propose to make up a unique name if an
| unnamed enum is used in two different translation units as a template
| argument?
They are different types, therefore have different internal "names" --
like unnamed namespaces.
-- Gaby
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (11 preceding siblings ...)
2005-03-26 22:53 ` bangerth at dealii dot org
@ 2005-03-27 3:18 ` gdr at integrable-solutions dot net
2005-08-05 3:43 ` sethml at google dot com
` (3 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-03-27 3:18 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2005-03-27 03:18 -------
Subject: Re: error: '<anonymous enum>' is/uses anonymous type'
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| Well, I wanted to give an "inuitive" reasoning.
I understood that; I just don't think they are conclusive :-)
| On the other hand, how do you propose to make up a unique name if an
| unnamed enum is used in two different translation units as a template
| argument?
They are different types, therefore have different internal "names" --
like unnamed namespaces.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (12 preceding siblings ...)
2005-03-27 3:18 ` gdr at integrable-solutions dot net
@ 2005-08-05 3:43 ` sethml at google dot com
2005-08-05 3:48 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: sethml at google dot com @ 2005-08-05 3:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From sethml at google dot com 2005-08-05 03:43 -------
The C++ working group examined this issue in April as core language issue 488:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#488
They tentatively concluded that type deduction should fail in this case, leaving
the built-in operator==(int,int) version as the only viable candidate and thus
the code attached to this bug report would compile.
It seems likely that this decision will hold, that the standard will be
clarified, making this code valid.
Can we get this bug re-opened, and perhaps change GCC 4 to accept this code in
anticipation of the C++ standard changing to explicitly allow it?
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |sethml at google dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (13 preceding siblings ...)
2005-08-05 3:43 ` sethml at google dot com
@ 2005-08-05 3:48 ` pinskia at gcc dot gnu dot org
2005-08-05 3:48 ` pinskia at gcc dot gnu dot org
2005-08-05 3:49 ` mark at codesourcery dot com
16 siblings, 0 replies; 19+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-05 3:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-05 03:48 -------
Reopening to ...
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (14 preceding siblings ...)
2005-08-05 3:48 ` pinskia at gcc dot gnu dot org
@ 2005-08-05 3:48 ` pinskia at gcc dot gnu dot org
2005-08-05 3:49 ` mark at codesourcery dot com
16 siblings, 0 replies; 19+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-05 3:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-05 03:48 -------
To suspend it as the DR is still in drafting.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |SUSPENDED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Bug c++/20589] error: '<anonymous enum>' is/uses anonymous type'
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
` (15 preceding siblings ...)
2005-08-05 3:48 ` pinskia at gcc dot gnu dot org
@ 2005-08-05 3:49 ` mark at codesourcery dot com
16 siblings, 0 replies; 19+ messages in thread
From: mark at codesourcery dot com @ 2005-08-05 3:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mark at codesourcery dot com 2005-08-05 03:49 -------
Subject: Re: error: '<anonymous enum>' is/uses anonymous type'
sethml at google dot com wrote:
> ------- Additional Comments From sethml at google dot com 2005-08-05 03:43 -------
> The C++ working group examined this issue in April as core language issue 488:
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#488
>
> They tentatively concluded that type deduction should fail in this case, leaving
> the built-in operator==(int,int) version as the only viable candidate and thus
> the code attached to this bug report would compile.
>
> It seems likely that this decision will hold, that the standard will be
> clarified, making this code valid.
>
> Can we get this bug re-opened, and perhaps change GCC 4 to accept this code in
> anticipation of the C++ standard changing to explicitly allow it?
Our normal practice has been not to do that until the issue is in at
least WP status.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20589
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2005-08-05 3:49 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-22 15:45 [Bug c++/20589] New: error: '<anonymous enum>' is/uses anonymous type' caolanm at redhat dot com
2005-03-22 15:46 ` [Bug c++/20589] " caolanm at redhat dot com
2005-03-22 16:10 ` pinskia at gcc dot gnu dot org
2005-03-22 16:16 ` mmitchel at gcc dot gnu dot org
2005-03-23 11:54 ` caolanm at redhat dot com
2005-03-23 16:57 ` pinskia at gcc dot gnu dot org
2005-03-23 18:53 ` bangerth at dealii dot org
2005-03-23 19:12 ` caolanm at redhat dot com
2005-03-23 19:24 ` bangerth at dealii dot org
2005-03-23 19:28 ` mark at codesourcery dot com
2005-03-23 21:56 ` bangerth at dealii dot org
2005-03-26 4:20 ` gdr at integrable-solutions dot net
2005-03-26 22:53 ` bangerth at dealii dot org
2005-03-27 3:18 ` Gabriel Dos Reis
2005-03-27 3:18 ` gdr at integrable-solutions dot net
2005-08-05 3:43 ` sethml at google dot com
2005-08-05 3:48 ` pinskia at gcc dot gnu dot org
2005-08-05 3:48 ` pinskia at gcc dot gnu dot org
2005-08-05 3:49 ` mark at codesourcery dot com
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).