F
Francesco
Hi there,
I was trying to work around the fact that there is no implicit
conversion from int to enum, and I stomped on something odd.
(actually, in the code I'm about to post, I snipped out the ctor
taking an int, which would work around the missing implicit conversion
- here the issue is different)
See this really simple snippet:
-------
#include <iostream>
using namespace std;
class Color {
public:
enum color { black, white };
color c;
Color(color cc = black) : c (cc) {}
};
int main()
{
int i = 0;
Color col(Color::color(i));
cout << col.c << endl;
return 0;
}
-------
Since it didn't compile on my old MinGW release, I've tried it on
Comeau Online, and it happened to give just the same results:
-------
Comeau C/C++ 4.3.10.1 (Oct 6 2008 11:28:09) for
ONLINE_EVALUATION_BETA2
Copyright 1988-2008 Comeau Computing. All rights reserved.
MODE:strict errors C++ C++0x_extensions
"ComeauTest.c", line 16: error: expression must have class type
cout << col.c << endl;
^
"ComeauTest.c", line 14: warning: variable "i" was declared but never
referenced
int i = 0;
^
1 error detected in the compilation of "ComeauTest.c".
In strict mode, with -tused, Compile failed
Hit the Back Button to review your code and compile options.
Compiled with C++0x extensions enabled.
-------
Changing this:
Color col(Color::color(i));
to this:
Color col(Color::black);
lets it compile with no problem whatsoever.
What do you think about? Should I report it to the Comeau team?
Cheers
Francesco
I was trying to work around the fact that there is no implicit
conversion from int to enum, and I stomped on something odd.
(actually, in the code I'm about to post, I snipped out the ctor
taking an int, which would work around the missing implicit conversion
- here the issue is different)
See this really simple snippet:
-------
#include <iostream>
using namespace std;
class Color {
public:
enum color { black, white };
color c;
Color(color cc = black) : c (cc) {}
};
int main()
{
int i = 0;
Color col(Color::color(i));
cout << col.c << endl;
return 0;
}
-------
Since it didn't compile on my old MinGW release, I've tried it on
Comeau Online, and it happened to give just the same results:
-------
Comeau C/C++ 4.3.10.1 (Oct 6 2008 11:28:09) for
ONLINE_EVALUATION_BETA2
Copyright 1988-2008 Comeau Computing. All rights reserved.
MODE:strict errors C++ C++0x_extensions
"ComeauTest.c", line 16: error: expression must have class type
cout << col.c << endl;
^
"ComeauTest.c", line 14: warning: variable "i" was declared but never
referenced
int i = 0;
^
1 error detected in the compilation of "ComeauTest.c".
In strict mode, with -tused, Compile failed
Hit the Back Button to review your code and compile options.
Compiled with C++0x extensions enabled.
-------
Changing this:
Color col(Color::color(i));
to this:
Color col(Color::black);
lets it compile with no problem whatsoever.
What do you think about? Should I report it to the Comeau team?
Cheers
Francesco