public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/46690] New: Using declaration of a dependent name
@ 2010-11-28 10:20 ilpoilves at hotmail dot com
2010-11-28 10:23 ` [Bug c++/46690] " ilpoilves at hotmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: ilpoilves at hotmail dot com @ 2010-11-28 10:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46690
Summary: Using declaration of a dependent name
Product: gcc
Version: 4.4.5
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ilpoilves@hotmail.com
Consider the following code:
template <typename T>
class A {public: typedef int C;};
template <typename T>
class B: public A<T>
{
public:
using typename A<T>::C;
C operator[](int i) const { return 0; }
};
int main()
{
B<int> b;
b[2];
return 0;
}
The compilation gives:
test.cpp:9: error: ISO C++ forbids declaration of 'C' with no type
test.cpp:9: error: expected ';' before 'operator'
test.cpp:10: error: expected ';' before '}' token
test.cpp: In function 'int main()':
test.cpp:15: error: no match for 'operator[]' in 'b[2]'
A discussion in comp.lang.c++ revealed that this feature was underspecified in
C++03. I propose the using declaration either just to work, or report a proper
error.
To see the intent, consider the current wording for C++0x:
From n3126 (C++0x draft from August 2010), §7.3.3:
"20. If a using-declaration uses the keyword typename and specifies a
dependent name (14.6.2), the name introduced
by the using-declaration is treated as a typedef-name (7.1.3)."
So the work-around here is
typedef typename A<T>::C C;
which is equivalent.
The code above is accepted at least by Visual Studio 2008, 2010, and Comeau
C++, all in strict mode.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/46690] Using declaration of a dependent name
2010-11-28 10:20 [Bug c++/46690] New: Using declaration of a dependent name ilpoilves at hotmail dot com
@ 2010-11-28 10:23 ` ilpoilves at hotmail dot com
2010-11-28 13:19 ` redi at gcc dot gnu.org
2010-11-29 19:18 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: ilpoilves at hotmail dot com @ 2010-11-28 10:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46690
--- Comment #1 from ilpoilves at hotmail dot com 2010-11-28 09:38:04 UTC ---
Here is the result of gcc -v, which was left out by accident.
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.4-8'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--with-arch-32=i586 --with-tune=generic --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.5 20100728 (prerelease) (Debian 4.4.4-8)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/46690] Using declaration of a dependent name
2010-11-28 10:20 [Bug c++/46690] New: Using declaration of a dependent name ilpoilves at hotmail dot com
2010-11-28 10:23 ` [Bug c++/46690] " ilpoilves at hotmail dot com
@ 2010-11-28 13:19 ` redi at gcc dot gnu.org
2010-11-29 19:18 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2010-11-28 13:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46690
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2010.11.28 12:08:05
Ever Confirmed|0 |1
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-11-28 12:08:05 UTC ---
With 4.5 you get a much better error:
use.cc:9:5: error: ‘C’ does not name a type
use.cc:9:5: note: (perhaps ‘typename A<T>::C’ was intended)
use.cc: In function ‘int main()’:
use.cc:15:8: error: no match for ‘operator[]’ in ‘b[2]’
But it should be accepted
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/46690] Using declaration of a dependent name
2010-11-28 10:20 [Bug c++/46690] New: Using declaration of a dependent name ilpoilves at hotmail dot com
2010-11-28 10:23 ` [Bug c++/46690] " ilpoilves at hotmail dot com
2010-11-28 13:19 ` redi at gcc dot gnu.org
@ 2010-11-29 19:18 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-11-29 19:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46690
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |DUPLICATE
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-11-29 19:13:27 UTC ---
This is the same bug as PR 14258.
*** This bug has been marked as a duplicate of bug 14258 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-11-29 19:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-28 10:20 [Bug c++/46690] New: Using declaration of a dependent name ilpoilves at hotmail dot com
2010-11-28 10:23 ` [Bug c++/46690] " ilpoilves at hotmail dot com
2010-11-28 13:19 ` redi at gcc dot gnu.org
2010-11-29 19:18 ` pinskia at gcc dot gnu.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).