Bug 48107 - [C++0x] no explicit conversion from scoped enumeration type to bool
Summary: [C++0x] no explicit conversion from scoped enumeration type to bool
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.5
: P3 normal
Target Milestone: 4.6.1
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-03-13 21:59 UTC by Jonathan Wakely
Modified: 2011-04-08 15:16 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.4.6, 4.5.3, 4.6.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2011-03-13 21:59:04 UTC
4.4, 4.5 and 4.6 all reject this code

enum class E { };

void f(E e) {
  static_cast<bool>(e);
}

e.C:4: error: invalid operands of types ‘E’ and ‘int’ to binary ‘operator!=’
Comment 1 Jason Merrill 2011-04-08 15:14:57 UTC
Fixed by r172138

        PR c++/48450
        * c-family/c-common.c (c_common_truthvalue_conversion): Don't ignore
        conversion from C++0x scoped enum.
        * cp/cvt.c (ocp_convert): Handle converting scoped enum to bool.
Comment 2 Jonathan Wakely 2011-04-08 15:16:58 UTC
excellent, thanks!