Bug 17327 - [3.3/3.4/4.0 Regression] use of `enumeral_type' in template type unification
Summary: [3.3/3.4/4.0 Regression] use of `enumeral_type' in template type unification
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: 3.4.3
Assignee: Mark Mitchell
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2004-09-05 12:50 UTC by Lars Hansen
Modified: 2004-09-14 00:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 2.95.3
Known to fail: 3.0.4 3.2.3 3.3.3 3.4.1 4.0.0
Last reconfirmed: 2004-09-06 14:27:22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Hansen 2004-09-05 12:50:48 UTC
Version:
--------
http://mesh.dl.sourceforge.net/sourceforge/mingw/gcc-core-3.4.1-20040711-
1.tar.gz

Using built-in specs.
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=
mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable
-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --e
nable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-ja
va-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchroniz
ation --enable-libstdcxx-debug

Thread model: win32

gcc version 3.4.1 (mingw special)




Compiler settings: 
------------------
g++.exe "F:\Daten\Projekte\CPP\trainingGNU\templates.cpp" -
o "F:\Daten\Projekte\CPP\trainingGNU\templates.exe"    -I"C:\Dev-
Cpp\include\c++\3.4.1"  -I"C:\Dev-Cpp\include\c++\3.4.1\mingw32"  -I"C:\Dev-
Cpp\include\c++\3.4.1\backward"  -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.1\include"  -
I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib" 




Messages:
---------
F:\Daten\Projekte\CPP\trainingGNU\templates.cpp: In instantiation of `A<E>':
F:\Daten\Projekte\CPP\trainingGNU\templates.cpp:47:   instantiated from here
F:\Daten\Projekte\CPP\trainingGNU\templates.cpp:24: sorry, unimplemented: use 
of `enumeral_type' in template type unification

F:\Daten\Projekte\CPP\trainingGNU\templates.cpp:24: sorry, unimplemented: use 
of `enumeral_type' in template type unification

F:\Daten\Projekte\CPP\trainingGNU\templates.cpp:24: sorry, unimplemented: use 
of `enumeral_type' in template type unification

F:\Daten\Projekte\CPP\trainingGNU\templates.cpp:24: sorry, unimplemented: use 
of `enumeral_type' in template type unification

F:\Daten\Projekte\CPP\trainingGNU\templates.cpp:24: sorry, unimplemented: use 
of `enumeral_type' in template type unification




Problem:
--------
The code can be compiled successfully with other compilers like Comeau or 
Borland BuilderX and runs proper.




Source:
-------
    #include <iostream>
    #include <cstdlib>
    using namespace std;
    
    //////////////////////////////////////////////////////////////////////
    
    enum E
    {
        E0,
        E1
    };
    
    //////////////////////////////////////////////////////////////////////
    
    template <typename T>
    class A;
    
    template <typename T>
    ostream& operator << (ostream& out, A<T> a);
    
    template <typename T>
    class A
    {
        friend ostream& operator << <T> (ostream& out, A<T> a);
        int mI;
    
    public:
        A(int i) { mI = i; }
    };
    
    template <typename T>
    ostream& operator << (ostream& out, A<T> a)
    {
        out << a.mI;
        return out;
    
    }

    //////////////////////////////////////////////////////////////////////
    
    int main()
    {
        A<int> a = 5;
    
        cout << a << endl;
    
        A<E> b = 4;
    
        cout << b << endl;
    
        system("Pause");
    
        return 0;
    }
Comment 1 Kriang Lerdsuwanakij 2004-09-06 14:27:22 UTC
Confirmed.  It has failed since GCC 3.0 - a regression to GCC 2.95.x.
Comment 2 Giovanni Bajo 2004-09-06 14:41:45 UTC
A reduced testcase is needed to analyze the bug, because it definetely has to 
do with some other operator<< for ostreams defined in the standard headers. Can 
anybody help?
Comment 3 Kriang Lerdsuwanakij 2004-09-06 17:16:16 UTC
A simple testcase:

enum E { E0, E1 };
template <class T,class U> class A {};
template <class T> void f(A<E,T>) {}
template void f(A<int,E>);
Comment 4 Mark Mitchell 2004-09-09 04:30:08 UTC
Mine.
Comment 5 CVS Commits 2004-09-14 00:29:08 UTC
Subject: Bug 17327

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-09-14 00:29:04

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog parser.c pt.c 
Added files:
	gcc/testsuite/g++.dg/parse: crash17.C 
	gcc/testsuite/g++.dg/template: enum3.C 

Log message:
	PR c++/16716
	* parser.c (cp_parser_parse_and_diagnose_invalid_type_name):
	Robustify.
	
	PR c++/17327
	* pt.c (unify): Add ENUMERAL_TYPE case.  Replace sorry with
	gcc_unreacable.
	
	PR c++/16716
	* g++.dg/parse/crash17.C: New test.
	
	PR c++/17327
	* g++.dg/template/enum3.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4279&r2=1.4280
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4348&r2=1.4349
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.245&r2=1.246
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.921&r2=1.922
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/crash17.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/enum3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 7 Mark Mitchell 2004-09-14 00:44:30 UTC
Fixed in GCC 3.4.3.