Bug 51593 - alias templates fail in dependent contexts requiring ::template
Summary: alias templates fail in dependent contexts requiring ::template
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-16 22:39 UTC by Alisdair Meredith
Modified: 2011-12-16 23:45 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alisdair Meredith 2011-12-16 22:39:54 UTC
The following code is sufficient to demonstrate:

template<typename T>
struct wrap {
template<typename U>
using type = U;
};

template<typename T>
struct test {
using type = wrap<T>::template type<T>;
};

I get the following errors from a gcc built around Dec 10, 2011:

main.cpp:9:10: error: expected nested-name-specifier before 'type'
main.cpp:9:10: error: using-declaration for non-member at class scope
main.cpp:9:15: error: expected ';' before '=' token
main.cpp:9:15: error: expected unqualified-id before '=' token

This idiom seems important for supporting C++11 allocators, which supply just such a dependent alias.

Version info from my GCC build (running on Mac OS/X 10.7.2)
Using built-in specs.
COLLECT_GCC=g++-mp-4.7
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin11/4.7.0/lto-wrapper
Target: x86_64-apple-darwin11
Configured with: ../gcc-4.7-20111210/configure --prefix=/opt/local --build=x86_64-apple-darwin11 --enable-languages=c,c++,objc,obj-c++ --libdir=/opt/local/lib/gcc47 --includedir=/opt/local/include/gcc47 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.7 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.7 --with-gxx-include-dir=/opt/local/include/gcc47/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --enable-stage1-checking --disable-multilib
Thread model: posix
gcc version 4.7.0 20111210 (experimental) (GCC)
Comment 1 Andrew Pinski 2011-12-16 22:48:40 UTC
This works:
using type = typename wrap<T>::template type<T>;

Which seems correct as you need to say "wrap<T>::template type<T>" is a type.
Comment 2 Alisdair Meredith 2011-12-16 23:18:27 UTC
Thanks, I thought I had tried that, but I guess not.
It seems reasonable to close this as user error.
Comment 3 Paolo Carlini 2011-12-16 23:45:47 UTC
Ok