Bug 46389 - instantiating a template with an enum gives
Summary: instantiating a template with an enum gives
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc   
(Show other bugs)
Version: 7.0
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2001-06-28 10:24 UTC by Need Real Name
Modified: 2007-04-18 16:34 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-01-22 12:29:47 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
test case with syntax fixes (289 bytes, text/plain)
2004-01-22 12:29 UTC, Nils Philippsen
no flags Details

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
        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:

Steps to Reproduce:
1. Compile the above program

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)

Note You need to log in before you can comment on or make changes to this bug.