Bug 46389 - instantiating a template with an enum gives
instantiating a template with an enum gives
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.0
All Linux
medium Severity low
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-06-28 06:24 EDT by Need Real Name
Modified: 2007-04-18 12:34 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-01-22 07:29:47 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
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 07:29 EST, Nils Philippsen
no flags Details

  None (edit)
Description Need Real Name 2001-06-28 06:24:27 EDT
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 07:29:18 EST
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.