public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51671] New: g++ fails to allow a redundant typedef if the redundant typedef depends on a template parameter
@ 2011-12-24  9:19 jwalden+ggo at mit dot edu
  2011-12-24  9:41 ` [Bug c++/51671] " jwalden+ggo at mit dot edu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jwalden+ggo at mit dot edu @ 2011-12-24  9:19 UTC (permalink / raw)
  To: gcc-bugs

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.)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/51671] g++ fails to allow a redundant typedef if the redundant typedef depends on a template parameter
  2011-12-24  9:19 [Bug c++/51671] New: g++ fails to allow a redundant typedef if the redundant typedef depends on a template parameter jwalden+ggo at mit dot edu
@ 2011-12-24  9:41 ` jwalden+ggo at mit dot edu
  2011-12-24 12:12 ` paolo.carlini at oracle dot com
  2011-12-24 12:20 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: jwalden+ggo at mit dot edu @ 2011-12-24  9:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jeff Walden (remove +ggo to email) <jwalden+ggo at mit dot edu> 2011-12-24 09:18:51 UTC ---
For what it's worth, clang also has this bug.  See
<http://llvm.org/bugs/show_bug.cgi?id=11630>, which is this bug plus an extra
testcase that GCC handles correctly.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/51671] g++ fails to allow a redundant typedef if the redundant typedef depends on a template parameter
  2011-12-24  9:19 [Bug c++/51671] New: g++ fails to allow a redundant typedef if the redundant typedef depends on a template parameter jwalden+ggo at mit dot edu
  2011-12-24  9:41 ` [Bug c++/51671] " jwalden+ggo at mit dot edu
@ 2011-12-24 12:12 ` paolo.carlini at oracle dot com
  2011-12-24 12:20 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-24 12:12 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-12-24
     Ever Confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-24 11:56:22 UTC ---
ICC is fine instead, indeed in my experience in quite a few cases tries to do
less at definition time. Delaying the check shouldn't be too hard.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/51671] g++ fails to allow a redundant typedef if the redundant typedef depends on a template parameter
  2011-12-24  9:19 [Bug c++/51671] New: g++ fails to allow a redundant typedef if the redundant typedef depends on a template parameter jwalden+ggo at mit dot edu
  2011-12-24  9:41 ` [Bug c++/51671] " jwalden+ggo at mit dot edu
  2011-12-24 12:12 ` paolo.carlini at oracle dot com
@ 2011-12-24 12:20 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-24 12:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-24 12:11:22 UTC ---
I suppose tweaking comp_array_types should do it...


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-12-24 12:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-24  9:19 [Bug c++/51671] New: g++ fails to allow a redundant typedef if the redundant typedef depends on a template parameter jwalden+ggo at mit dot edu
2011-12-24  9:41 ` [Bug c++/51671] " jwalden+ggo at mit dot edu
2011-12-24 12:12 ` paolo.carlini at oracle dot com
2011-12-24 12:20 ` 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).