This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82304] New: GCC compiles constexpr function with double reinterpret_cast in a constant context
- From: "vladimir.krivopalov at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 23 Sep 2017 02:39:43 +0000
- Subject: [Bug c++/82304] New: GCC compiles constexpr function with double reinterpret_cast in a constant context
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82304
Bug ID: 82304
Summary: GCC compiles constexpr function with double
reinterpret_cast in a constant context
Product: gcc
Version: 7.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vladimir.krivopalov at gmail dot com
Target Milestone: ---
The following code compiles fine with GCC (-std=c++14) although normally it
should be rejected:
#include <cstdint>
inline constexpr const char* testfunc(const char* p)
{
return reinterpret_cast<const char*> (
reinterpret_cast<uintptr_t>(p));
}
int main(int argc, char** argv) {
static constexpr const char* second = testfunc("Hello");
}
The C+14 standard prohibits use of reinterpret_cast in constexpr functions:
[expr.const]/2.11 and [expr.const]/2.13