public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33093]  New: ICE in C++ frontend with constant defined in template specialization
@ 2007-08-16 20:49 ian at airs dot com
  2007-08-16 21:01 ` [Bug c++/33093] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: ian at airs dot com @ 2007-08-16 20:49 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]

When I compile this test case with gcc 4.1, 4.2, or mainline, I get an ICE:

foo.cc: In instantiation of ‘const unsigned char B<unsigned char>::c’:
foo.cc:20:   instantiated from ‘const unsigned char C<A<unsigned char> >::c’
foo.cc:26:   instantiated from here
foo.cc:20: internal compiler error: in instantiate_decl, at cp/pt.c:14162

As far as I can see this is valid C++ code.

template<typename T> class A
{
public:
  typedef T T1;
};

template<typename T> class B
{
public:
  static const T c;
};

template<unsigned char>
const unsigned char B<unsigned char>::c = 1;

template<typename T> class C
{
public:
  typedef typename T::T1 T2;
  static const T2 c = B<T2>::c;
};

unsigned char
fn ()
{
  return C<A<unsigned char> >::c;
}


-- 
           Summary: ICE in C++ frontend with constant defined in template
                    specialization
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


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


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

* [Bug c++/33093] ICE in C++ frontend with constant defined in template specialization
  2007-08-16 20:49 [Bug c++/33093] New: ICE in C++ frontend with constant defined in template specialization ian at airs dot com
@ 2007-08-16 21:01 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-08-16 21:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-08-16 21:01 -------
>As far as I can see this is valid C++ code.
It is not but the way to fix it is doing:
template<>
const unsigned char B<unsigned char>::c = 1;

----- cut ------
This is a dup of bug 24791

*** This bug has been marked as a duplicate of 24791 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2007-08-16 21:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-16 20:49 [Bug c++/33093] New: ICE in C++ frontend with constant defined in template specialization ian at airs dot com
2007-08-16 21:01 ` [Bug c++/33093] " pinskia at gcc dot gnu dot 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).