public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18020] New: issue with enum in a template
@ 2004-10-15 18:05 gmorin1 at bloomberg dot net
2004-10-15 18:21 ` [Bug c++/18020] " pinskia at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: gmorin1 at bloomberg dot net @ 2004-10-15 18:05 UTC (permalink / raw)
To: gcc-bugs
Here we go:
gmorin@linux:~> cat foo.cpp
template <typename FOO>
struct bar {
enum {
MASK = ((1 << 17)-1)
, IT_MASK = (~MASK)
, ITERATION_INC = (MASK+1)
};
};
int baz = bar<int>::IT_MASK;
gmorin@linux:~> g++ -o /dev/null -c foo.cpp
foo.cpp: In instantiation of `bar<int>':
foo.cpp:10: instantiated from here
foo.cpp:3: error: enumerator value for `IT_MASK' not integer constant
gmorin@linux:~> gcc -v
Reading specs from /openpkg/lib/gcc/i686-pc-linux-gnu/3.4.2/specs
Configured with: ../configure --cache-file=./config.cache
--srcdir=/openpkg/RPM/TMP/gcc-3.4.2/obj/.. --prefix=/openpkg
--exec-prefix=/openpkg --includedir=/openpkg/include/gcc
--libexecdir=/openpkg/libexec/gcc --with-gxx-include-dir=/openpkg/include/g++
--with-local-prefix=/openpkg/lib/gcc --enable-languages=c,c++
--enable-threads=posix --disable-maintainer-mode --disable-shared --disable-nls
--with-gnu-ld --with-ld=/openpkg/bin/ld --with-gnu-as --with-as=/openpkg/bin/as
Thread model: posix
gcc version 3.4.2 (OpenPKG-CURRENT)
gmorin@linux:~> uname -a
Linux linux 2.4.21-99-smp4G #1 SMP Wed Sep 24 14:13:20 UTC 2003 i686 athlon i386
GNU/Linux
This is a Suse 9.0 with gcc from CURRENT OpenPKG. It works if you remove the
template declaration.
--
Summary: issue with enum in a template
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gmorin1 at bloomberg dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18020
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18020] issue with enum in a template
2004-10-15 18:05 [Bug c++/18020] New: issue with enum in a template gmorin1 at bloomberg dot net
@ 2004-10-15 18:21 ` pinskia at gcc dot gnu dot org
2004-10-15 18:57 ` bangerth at dealii dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-15 18:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-15 18:21 -------
Hmm, this works for me on 3.4.2, can you try not with a OpenPKG package?
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18020
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18020] issue with enum in a template
2004-10-15 18:05 [Bug c++/18020] New: issue with enum in a template gmorin1 at bloomberg dot net
2004-10-15 18:21 ` [Bug c++/18020] " pinskia at gcc dot gnu dot org
@ 2004-10-15 18:57 ` bangerth at dealii dot org
2004-10-15 19:07 ` gmorin1 at bloomberg dot net
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-10-15 18:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-10-15 18:57 -------
I can't reproduce this with 3.4.3 20041015 (prerelease) either. It must
be a local patch in OpenPKG then.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution| |WORKSFORME
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18020
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18020] issue with enum in a template
2004-10-15 18:05 [Bug c++/18020] New: issue with enum in a template gmorin1 at bloomberg dot net
2004-10-15 18:21 ` [Bug c++/18020] " pinskia at gcc dot gnu dot org
2004-10-15 18:57 ` bangerth at dealii dot org
@ 2004-10-15 19:07 ` gmorin1 at bloomberg dot net
2004-10-15 19:17 ` [Bug c++/18020] [3.4/4.0 regression] rejects valid definition of enum value in template bangerth at dealii dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: gmorin1 at bloomberg dot net @ 2004-10-15 19:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gmorin1 at bloomberg dot net 2004-10-15 19:07 -------
Hi,
As far as I know, OpenPKG does not apply any patched on this gcc. Furthermore, I
have another gcc 3.4.2 built from the vanilla source on Solaris :
gmorin@sundev9:~$ /unix-SunOS-sparc-5.8-def/bin/g++ -o /dev/null -c foo.cpp
foo.cpp: In instantiation of `bar<int>':
foo.cpp:11: instantiated from here
foo.cpp:3: error: enumerator value for `IT_MASK' not integer constant
gmorin@sundev9:~$ /unix-SunOS-sparc-5.8-def/bin/g++ -v
Reading specs from
/unix-SunOS-sparc-5.8-def/bin/../lib/gcc/sparc-sun-solaris2.8/3.4.2/specs
Configured with: ../gcc-3.4.2/configure --prefix=/unix-SunOS-sparc-5.8-def/
--enable-languages=c,c++
Thread model: posix
gcc version 3.4.2
gmorin@sundev9:~$ uname -a
SunOS sundev9 5.8 Generic_108528-19 sun4u sparc SUNW,Sun-Fire
gmorin@sundev9:~$
I strongly think this bug should be reopened. It looks extremely likely that it
is present in 3.4.2, and it is not sure yet it is fixed 3.4.3.
Thanks,
Guillaume.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18020
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18020] [3.4/4.0 regression] rejects valid definition of enum value in template
2004-10-15 18:05 [Bug c++/18020] New: issue with enum in a template gmorin1 at bloomberg dot net
` (3 preceding siblings ...)
2004-10-15 19:17 ` [Bug c++/18020] [3.4/4.0 regression] rejects valid definition of enum value in template bangerth at dealii dot org
@ 2004-10-15 19:17 ` bangerth at dealii dot org
2004-10-15 19:43 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-10-15 19:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-10-15 19:17 -------
Confirmed indeed. Sorry for my initial oversight...
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-10-15 19:17:30
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18020
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18020] [3.4/4.0 regression] rejects valid definition of enum value in template
2004-10-15 18:05 [Bug c++/18020] New: issue with enum in a template gmorin1 at bloomberg dot net
` (2 preceding siblings ...)
2004-10-15 19:07 ` gmorin1 at bloomberg dot net
@ 2004-10-15 19:17 ` bangerth at dealii dot org
2004-10-15 19:17 ` bangerth at dealii dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-10-15 19:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-10-15 19:17 -------
My fault: I missed the last line of the testcase where the instantiation
is. With this line I can reproduce this bug with both stock 3.4.2 as well
as with the present top-of-branch 3.4 compiler.
The bug doesn't happen with gcc 3.3, which makes this a regression. Here's
the testcase in slightly modified version:
------------------
template <typename> struct bar {
enum {
e1 = 1,
e2 = ~e1
};
};
template struct bar<int>;
--------------------
g/x> /home/bangerth/bin/gcc-4*/bin/c++ -c x.cc
x.cc: In instantiation of `bar<int>':
x.cc:7: instantiated from here
x.cc:2: error: enumerator value for 'e2' not integer constant
The problem doesn't happen when the class isn't a template.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Keywords| |rejects-valid
Known to fail| |3.4.2 3.4.3 4.0.0
Known to work| |3.3.4
Resolution|WORKSFORME |
Summary|issue with enum in a |[3.4/4.0 regression] rejects
|template |valid definition of enum
| |value in template
Target Milestone|--- |3.4.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18020
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18020] [3.4/4.0 regression] rejects valid definition of enum value in template
2004-10-15 18:05 [Bug c++/18020] New: issue with enum in a template gmorin1 at bloomberg dot net
` (4 preceding siblings ...)
2004-10-15 19:17 ` bangerth at dealii dot org
@ 2004-10-15 19:43 ` pinskia at gcc dot gnu dot org
2004-10-26 22:15 ` mmitchel at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-15 19:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-15 19:43 -------
And mine too.
: Search converges between 2003-07-05-trunk (#285) and 2003-07-06-trunk (#286).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18020
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18020] [3.4/4.0 regression] rejects valid definition of enum value in template
2004-10-15 18:05 [Bug c++/18020] New: issue with enum in a template gmorin1 at bloomberg dot net
` (5 preceding siblings ...)
2004-10-15 19:43 ` pinskia at gcc dot gnu dot org
@ 2004-10-26 22:15 ` mmitchel at gcc dot gnu dot org
2004-10-27 2:23 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-10-26 22:15 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |mark at codesourcery dot com
|dot org |
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18020
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18020] [3.4/4.0 regression] rejects valid definition of enum value in template
2004-10-15 18:05 [Bug c++/18020] New: issue with enum in a template gmorin1 at bloomberg dot net
` (6 preceding siblings ...)
2004-10-26 22:15 ` mmitchel at gcc dot gnu dot org
@ 2004-10-27 2:23 ` cvs-commit at gcc dot gnu dot org
2004-10-27 4:33 ` cvs-commit at gcc dot gnu dot org
2004-10-27 4:33 ` mmitchel at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-27 2:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-10-27 02:23 -------
Subject: Bug 18020
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: mmitchel@gcc.gnu.org 2004-10-27 02:23:16
Modified files:
gcc/testsuite : ChangeLog
gcc/cp : ChangeLog decl.c name-lookup.c parser.c pt.c
search.c typeck.c
Added files:
gcc/testsuite/g++.dg/lookup: ns2.C
gcc/testsuite/g++.dg/template: enum4.C expr1.C
Log message:
PR c++/18093
* search.c (current_scope): Return the innermost non-block scope,
not the innermost non-block, non-namespace scope.
(at_namespace_scope_p): Adjust accordingly.
(dfs_accessible_post): Do not pass namespaces to is_friend.
(dfs_walk_once_accessible_r): Likewise.
* decl.c (grokvardecl): Adjust call to current_scope.
(build_enumerator): Likewise.
* parser.c (cp_parser_using_declaration): Likewise.
(cp_parser_direct_declarator): Use at_namespace_scope_p instead of
current_scope.
(cp_parser_class_head): Adjust call to current_scope.
* name-lookup.c (do_namespace_alias): Set the DECL_CONTEXT for the
alias.
PR c++/18020
* pt.c (tusbst_copy_and_build): Resolve enumeration constants to
their underlying values.
PR c++/18161
* typeck.c (build_binary_op): Honor build_type, even when in a
template.
PR c++/18093
* g++.dg/lookup/ns2.C: New test.
PR c++/18020
* g++.dg/template/enum4.C: New test.
PR c++/18161
* g++.dg/template/expr1.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4501&r2=1.4502
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4454&r2=1.4455
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1318&r2=1.1319
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&r1=1.87&r2=1.88
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.270&r2=1.271
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.937&r2=1.938
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/search.c.diff?cvsroot=gcc&r1=1.335&r2=1.336
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.588&r2=1.589
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/ns2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/enum4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/expr1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18020
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18020] [3.4/4.0 regression] rejects valid definition of enum value in template
2004-10-15 18:05 [Bug c++/18020] New: issue with enum in a template gmorin1 at bloomberg dot net
` (8 preceding siblings ...)
2004-10-27 4:33 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-27 4:33 ` mmitchel at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-10-27 4:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-10-27 04:33 -------
Fixed in GCC 3.4.3.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18020
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18020] [3.4/4.0 regression] rejects valid definition of enum value in template
2004-10-15 18:05 [Bug c++/18020] New: issue with enum in a template gmorin1 at bloomberg dot net
` (7 preceding siblings ...)
2004-10-27 2:23 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-27 4:33 ` cvs-commit at gcc dot gnu dot org
2004-10-27 4:33 ` mmitchel at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-27 4:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-10-27 04:33 -------
Subject: Bug 18020
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_4-branch
Changes by: mmitchel@gcc.gnu.org 2004-10-27 04:32:57
Modified files:
gcc/testsuite : ChangeLog
gcc/cp : ChangeLog name-lookup.c pt.c
Added files:
gcc/testsuite/g++.dg/lookup: ns2.C
gcc/testsuite/g++.dg/template: enum4.C
Log message:
PR c++/18093
* search.c (current_scope): Return the innermost non-block scope,
not the innermost non-block, non-namespace scope.
(at_namespace_scope_p): Adjust accordingly.
(dfs_accessible_post): Do not pass namespaces to is_friend.
(dfs_walk_once_accessible_r): Likewise.
* decl.c (grokvardecl): Adjust call to current_scope.
(build_enumerator): Likewise.
* parser.c (cp_parser_using_declaration): Likewise.
(cp_parser_direct_declarator): Use at_namespace_scope_p instead of
current_scope.
(cp_parser_class_head): Adjust call to current_scope.
* name-lookup.c (do_namespace_alias): Set the DECL_CONTEXT for the
alias.
PR c++/18020
* pt.c (tusbst_copy_and_build): Resolve enumeration constants to
their underlying values.
PR c++/18093
* g++.dg/lookup/ns2.C: New test.
PR c++/18020
* g++.dg/template/enum4.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.297&r2=1.3389.2.298
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/ns2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/enum4.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.171&r2=1.3892.2.172
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.34.2.18&r2=1.34.2.19
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.43&r2=1.816.2.44
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18020
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-10-27 4:33 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-15 18:05 [Bug c++/18020] New: issue with enum in a template gmorin1 at bloomberg dot net
2004-10-15 18:21 ` [Bug c++/18020] " pinskia at gcc dot gnu dot org
2004-10-15 18:57 ` bangerth at dealii dot org
2004-10-15 19:07 ` gmorin1 at bloomberg dot net
2004-10-15 19:17 ` [Bug c++/18020] [3.4/4.0 regression] rejects valid definition of enum value in template bangerth at dealii dot org
2004-10-15 19:17 ` bangerth at dealii dot org
2004-10-15 19:43 ` pinskia at gcc dot gnu dot org
2004-10-26 22:15 ` mmitchel at gcc dot gnu dot org
2004-10-27 2:23 ` cvs-commit at gcc dot gnu dot org
2004-10-27 4:33 ` cvs-commit at gcc dot gnu dot org
2004-10-27 4:33 ` mmitchel at gcc dot gnu 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).