Title
reinterpret_cast in constant expressions
Status
nad
Section
7.7 [expr.const]
Submitter
Daniel Krügler

Created on 2011-08-30.00:00:00 last changed 146 months ago

Messages

Date: 2012-10-15.00:00:00

Rationale (October, 2012):

Although reinterpret_cast was permitted in address constant expressions in C++03, this restriction has been implemented in some compilers and has not proved to break significant amounts of code. CWG deemed that the complications of dealing with pointers whose tpes changed (pointer arithmetic and dereference could not be permitted on such pointers) outweighed the possible utility of relaxing the current restriction.

Date: 2022-11-20.07:54:16

reinterpret_cast was forbidden in constant expressions to prevent type-punning operations at compile time. This may have been too strict, as there are uses for the operator that do not involve type punning. For example, a portable implementation of the addressof function could be written as a constexpr function if reinterpret_cast could be used in a constant expression.

History
Date User Action Args
2012-11-03 00:00:00adminsetmessages: + msg4174
2012-11-03 00:00:00adminsetstatus: open -> nad
2011-08-30 00:00:00admincreate