- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I can't seem to get scoped enums to work as case labels in a switch block in the Linux compiler. The following compiles fine on Windows but failed on Linux:
[cpp]
#include <iostream>
int main ( int argc, char * argv [] ) {
enum class scoped_enum {
AA, BB, CC, DD
};
scoped_enum test (scoped_enum::AA);
switch (test) {
case scoped_enum::AA:
std::cout << "AA" << std::endl;
break;
case scoped_enum::BB:
std::cout << "BB" << std::endl;
break;
case scoped_enum::CC:
std::cout << "CC" << std::endl;
break;
case scoped_enum::DD:
std::cout << "DD" << std::endl;
break;
}
return 0;
}
[/cpp]
[plain]
bmenadue@weyl ~/bmenadue/Code/testing>icpc --version
icpc (ICC) 13.1.1 20130313
Copyright (C) 1985-2013 Intel Corporation. All rights reserved.
bmenadue@weyl ~/bmenadue/Code/testing>icpc test.cpp -std=c++0x
test.cpp(12): error: expression must have integral or unscoped enum type
case scoped_enum::AA:
^
test.cpp(15): error: expression must have integral or unscoped enum type
case scoped_enum::BB:
^
test.cpp(18): error: expression must have integral or unscoped enum type
case scoped_enum::CC:
^
test.cpp(21): error: expression must have integral or unscoped enum type
case scoped_enum::DD:
^
compilation aborted for test.cpp (code 2)
[/plain]
Is this a compiler bug, or am I doing something wrong (thought it would be a common issue but I couldn't find any other threads about it)?
Thanks,
Ben
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:
Please take a look at a similar thread and Judith provided a description of the problem...
Ah, thanks Sergey. That's it; looks like I missed that thread when I was searching.
I'll just use an unscoped enum until it's fixed.
Cheers,
Ben

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page