This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/47144] [4.5 Regression] Doesn't reject attempt to define type in template argument; results in weird parse
- From: "schaub.johannes at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 1 Jan 2011 18:11:30 +0000
- Subject: [Bug c++/47144] [4.5 Regression] Doesn't reject attempt to define type in template argument; results in weird parse
- Auto-submitted: auto-generated
- References: <bug-47144-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47144
--- Comment #2 from Johannes Schaub <schaub.johannes at googlemail dot com> 2011-01-01 18:11:27 UTC ---
(In reply to comment #1)
> 4.4 rejects it:
>
> inv.cc:1: error: expected class-name before âintâ
> inv.cc:1: error: expected â(â before âintâ
>
> 4.5 accepts it without error
>
> current 4.6 rejects it with the following
>
> inv.cc:1:48: error: expected â;â after struct definition
> inv.cc:1:48: error: expected template-argument before â;â token
> inv.cc:1:48: error: expected â>â before â;â token
> inv.cc:1:48: error: expected â::â before â;â token
> inv.cc:1:48: error: expected unqualified-id before â;â token
> inv.cc:1:48: error: declaration does not declare anything [-fpermissive]
> inv.cc:1:50: error: expected unqualified-id before â>â token
>
> what 4.6.0 version are you using?
Hmm, "4.6.0 20101113 (experimental)". I found the following does not error out
on 4.1.2:
template<typename T> struct A { };
template<typename T>
struct C {
typename A< struct B { } >::A x;
};
C<int> c;
Maybe it also works on 4.4. Note that this relies on "typename X::Y" to ignore
non-type names, which I think is not according to the spec. See
http://stackoverflow.com/questions/4420828/another-bug-in-g-clang-c-templates-are-fun
and http://llvm.org/bugs/show_bug.cgi?id=8263 .