Bug 46389

Summary: instantiating a template with an enum gives
Product: [Retired] Red Hat Linux Reporter: Need Real Name <daniel_collins>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact: David Lawrence <dkl>
Severity: low Docs Contact:
Priority: medium    
Version: 7.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-01-22 12:29:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
test case with syntax fixes none

Description Need Real Name 2001-06-28 10:24:27 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)

Description of problem:
I have created a template class that I then try to instantiate with an 
enumeration (rather than a simple int/char or class) and I get an error in 
the default constructor about converting an int to an enumeration.

class Test
{
    public:
        T first;

        Test() : first()
        {
        }
};

enum DataType{DATE_TYPE=1, CHAR_TYPE=2};

int main(int argc, char *argv[])
{
    DataType test;          // Ok
    Test<DataType> test3;   // gives a warning

    return 0;
}


How reproducible:
Always

Steps to Reproduce:
1. Compile the above program
2.
3.
	

Actual Results:  I get an error on the template instantiation about 
conversion from int to enum DataType.

Expected Results:  This gives a warning in egcs-1.1.2.

Additional info:

I know this has increased from a warning to error in gcc 2.96, and I get 
round it via -fenum-int-equiv or -fpermissive, but since it is an error I 
guess I am doing something wrong. So
a) am I doing something wrong
b) how I should correct my code

Comment 1 Nils Philippsen 2004-01-22 12:29:18 UTC
Created attachment 97161 [details]
test case with syntax fixes

The attached code doesn't show the problem on gcc-3.2.3-24 (RHEL3) and
gcc-3.3.2-6 (FC1)