This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/51671] New: g++ fails to allow a redundant typedef if the redundant typedef depends on a template parameter


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51671

             Bug #: 51671
           Summary: g++ fails to allow a redundant typedef if the
                    redundant typedef depends on a template parameter
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jwalden+ggo@mit.edu


[jwalden@wheres-wally reduction]$ cat minimal.cpp 
template <int T>
struct S
{
  static void f()
  {
    typedef int q[1];
    typedef int q[T];
  }
};
[jwalden@wheres-wally reduction]$ ~/Programs/gcc-build/prefixdir/bin/g++
minimal.cpp 
minimal.cpp: In static member function âstatic void S<T>::f()â:
minimal.cpp:7:20: error: conflicting declaration âtypedef int q [T]â
minimal.cpp:6:17: error: âqâ has a previous declaration as âtypedef int q [1]â
[jwalden@wheres-wally reduction]$ (cd ~/Programs/gcc-build/trunk/ && svn info)
Path: .
URL: svn://gcc.gnu.org/svn/gcc/trunk
Repository Root: svn://gcc.gnu.org/svn/gcc
Repository UUID: 138bc75d-0d04-0410-961f-82ee72b054a4
Revision: 182676
Node Kind: directory
Schedule: normal
Last Changed Author: torvald
Last Changed Rev: 182676
Last Changed Date: 2011-12-23 20:42:48 -0500 (Fri, 23 Dec 2011)

If S is only instantiated with T = 1, the second typedef redefines q to the
same type as the first, so it should be allowed.

I happened to hit this while attempting to roll my own static_assert macro. 
(The C++11 static_assert isn't an option for various reasons.)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]