public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54309] New: type alias accessing class template enum type member fails
@ 2012-08-18 5:16 paul at preney dot ca
2012-08-18 6:02 ` [Bug c++/54309] [C++11] " pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: paul at preney dot ca @ 2012-08-18 5:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54309
Bug #: 54309
Summary: type alias accessing class template enum type member
fails
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: paul@preney.ca
Created attachment 28046
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28046
Source code demonstrating the bug.
This is easier to see not working than to describe. The code that does not work
(i.e., "not ok: BUG" comment in the example) works if you replace the using
type alias with a typedef instead though (which means that is a work-around for
now).
This bug was tested with these versions of GCC:
g++ v4.7.0
g++ v4.8.0 (snapshot 20120812)
The error message (from GCC v4.8):
$ g++-4.8.0-alpha20120812 -std=c++11 gcc-cxx-bug.cxx
gcc-cxx-bug.cxx: In instantiation of ‘void func() [with T = int]’:
gcc-cxx-bug.cxx:25:13: required from here
gcc-cxx-bug.cxx:15:24: error: no type named ‘Stuff’ in ‘using test = class
Foo<T>’
typename test::Stuff b = test::Stuff::beta; // not ok: BUG
^
gcc-cxx-bug.cxx:15:24: error: no type named ‘Stuff’ in ‘using test = class
Foo<T>’
gcc-cxx-bug.cxx:15:24: error: no type named ‘Stuff’ in ‘using test = class
Foo<T>’
$
(I also tried this code with clang++ (v3.1) and it compiles successfully as
expected.)
It appears to only occur when a using type alias (i.e., the "test" alias in the
example) is used to access a template class' member that is an enum type (i.e.,
"Foo<T>::Stuff" in the example) when the class template parameter is not
hard-coded using the using type alias (i.e., Foo<T> is used but Foo<int> is
okay). The code triggering the issue follows and is attached.
template <typename T>
class Foo
{
public:
enum class Stuff { alpha, beta };
};
template <typename T>
void func()
{
typename Foo<T>::Stuff a = Foo<T>::Stuff::alpha; // ok
a = a;
using test = Foo<T>;
typename test::Stuff b = test::Stuff::beta; // not ok: BUG
b = b;
typedef Foo<T> test2;
typename test2::Stuff c = test2::Stuff::beta; // ok
c = c;
}
int main()
{
func<int>();
{
Foo<int>::Stuff a = Foo<int>::Stuff::alpha; // ok
a = a;
using test = Foo<int>;
typename test::Stuff b = test::Stuff::beta; // ok
b = b;
typedef Foo<int> test2;
typename test2::Stuff c = test2::Stuff::beta; // ok
c = c;
}
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/54309] [C++11] type alias accessing class template enum type member fails
2012-08-18 5:16 [Bug c++/54309] New: type alias accessing class template enum type member fails paul at preney dot ca
@ 2012-08-18 6:02 ` pinskia at gcc dot gnu.org
2012-08-18 6:05 ` [Bug c++/54309] [C++11] type alias accessing class template typename pinskia at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-08-18 6:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54309
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |rejects-valid
Last reconfirmed| |2012-08-18
Ever Confirmed|0 |1
Summary|type alias accessing class |[C++11] type alias
|template enum type member |accessing class template
|fails |enum type member fails
Severity|major |normal
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-08-18 06:02:03 UTC ---
It looks like the using alias is not setup to late bind.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/54309] [C++11] type alias accessing class template typename
2012-08-18 5:16 [Bug c++/54309] New: type alias accessing class template enum type member fails paul at preney dot ca
2012-08-18 6:02 ` [Bug c++/54309] [C++11] " pinskia at gcc dot gnu.org
@ 2012-08-18 6:05 ` pinskia at gcc dot gnu.org
2012-08-18 9:40 ` paolo.carlini at oracle dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-08-18 6:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54309
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[C++11] type alias |[C++11] type alias
|accessing class template |accessing class template
|enum type member fails |typename
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-08-18 06:05:37 UTC ---
Also enum is not the only issue, it is an issue with any subnames of the type
alias.
template <typename T>
struct Foo
{
typedef int Stuff;
};
template <typename T>
void func()
{
typename Foo<T>::Stuff a = 1;
a = a;
using test = Foo<T>;
typename test::Stuff b;
b = b;
typedef Foo<T> test2;
typename test2::Stuff c = 2;
c = c;
}
int main()
{
func<int>();
{
Foo<int>::Stuff a = 1;
a = a;
using test = Foo<int>;
typename test::Stuff b = 2;
b = b;
typedef Foo<int> test2;
typename test2::Stuff c = 3;
c = c;
}
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/54309] [C++11] type alias accessing class template typename
2012-08-18 5:16 [Bug c++/54309] New: type alias accessing class template enum type member fails paul at preney dot ca
2012-08-18 6:02 ` [Bug c++/54309] [C++11] " pinskia at gcc dot gnu.org
2012-08-18 6:05 ` [Bug c++/54309] [C++11] type alias accessing class template typename pinskia at gcc dot gnu.org
@ 2012-08-18 9:40 ` paolo.carlini at oracle dot com
2012-08-20 12:10 ` dodji at seketeli dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-08-18 9:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54309
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dodji at gcc dot gnu.org
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-18 09:40:35 UTC ---
Maybe Dodji is willing to have a look to this one too.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/54309] [C++11] type alias accessing class template typename
2012-08-18 5:16 [Bug c++/54309] New: type alias accessing class template enum type member fails paul at preney dot ca
` (2 preceding siblings ...)
2012-08-18 9:40 ` paolo.carlini at oracle dot com
@ 2012-08-20 12:10 ` dodji at seketeli dot org
2012-08-20 12:12 ` paolo.carlini at oracle dot com
2013-05-03 9:54 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: dodji at seketeli dot org @ 2012-08-20 12:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54309
--- Comment #4 from dodji at seketeli dot org <dodji at seketeli dot org> 2012-08-20 12:10:27 UTC ---
I think this is the same problem as PR c++/53540 for which a candidate
patch was sent to the gcc-patches mailing list [1].
So unless I am mistaken, I am marking this bug as a duplicate of the
former.
[1]: http://gcc.gnu.org/ml/gcc-patches/2012-08/msg01111.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/54309] [C++11] type alias accessing class template typename
2012-08-18 5:16 [Bug c++/54309] New: type alias accessing class template enum type member fails paul at preney dot ca
` (3 preceding siblings ...)
2012-08-20 12:10 ` dodji at seketeli dot org
@ 2012-08-20 12:12 ` paolo.carlini at oracle dot com
2013-05-03 9:54 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-08-20 12:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54309
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-20 12:12:44 UTC ---
Ah great, I suspected that.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/54309] [C++11] type alias accessing class template typename
2012-08-18 5:16 [Bug c++/54309] New: type alias accessing class template enum type member fails paul at preney dot ca
` (4 preceding siblings ...)
2012-08-20 12:12 ` paolo.carlini at oracle dot com
@ 2013-05-03 9:54 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-03 9:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54309
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Known to work| |4.8.0, 4.9.0
Resolution| |DUPLICATE
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-05-03 09:54:21 UTC ---
Thus this works in the released 4.8.0.
*** This bug has been marked as a duplicate of bug 53540 ***
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-05-03 9:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-18 5:16 [Bug c++/54309] New: type alias accessing class template enum type member fails paul at preney dot ca
2012-08-18 6:02 ` [Bug c++/54309] [C++11] " pinskia at gcc dot gnu.org
2012-08-18 6:05 ` [Bug c++/54309] [C++11] type alias accessing class template typename pinskia at gcc dot gnu.org
2012-08-18 9:40 ` paolo.carlini at oracle dot com
2012-08-20 12:10 ` dodji at seketeli dot org
2012-08-20 12:12 ` paolo.carlini at oracle dot com
2013-05-03 9:54 ` paolo.carlini at oracle 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).