On Mon, Jan 30, 2012 at 6:01 PM, Richard Smith <[email protected]> wrote: > On Mon, Jan 30, 2012 at 4:29 PM, Eli Friedman <[email protected]> > wrote: >> >> On Mon, Jan 30, 2012 at 2:27 PM, Richard Smith >> <[email protected]> wrote: >> > Author: rsmith >> > Date: Mon Jan 30 16:27:01 2012 >> > New Revision: 149286 >> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=149286&view=rev >> > Log: >> > constexpr: disallow signed integer overflow in integral conversions in >> > constant >> > expressions in C++11. >> >> Standard citation? As far as I can tell, the result of >> (int)0x80000000u is implementation-defined, but it's still a constant >> expression given how we define it. > > > Oops, r149327. This was (incorrectly) factored out of another change which > I'm still questioning... Consider: > > enum E { n = 2 }; > E e = (E)5; > > 5 is not in the range of values of the enumeration (which is 0..3 by > [dcl.enum]p7), but is clearly in the underlying type. Is this value in the > range of representable values for its type (or is this undefined behavior by > [expr]p4)?
I think the relevant passage is actually [expr.static.cast]p10: A value of integral or enumeration type can be explicitly converted to an enumeration type. The value is unchanged if the original value is within the range of the enumeration values (7.2). Otherwise, the resulting value is unspecified (and might not be in that range). That doesn't sound like undefined behavior to me. -Eli _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
