| Summary: | conformance issue with reinterpret_cast in constant expressions | ||
|---|---|---|---|
| Product: | gcc | Reporter: | Darrell Wright <Darrell.Wright> |
| Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
| Status: | NEW --- | ||
| Severity: | normal | CC: | mpolacek, webrown.cpp, wjwray |
| Priority: | P3 | Keywords: | accepts-invalid |
| Version: | unknown | ||
| Target Milestone: | --- | ||
| See Also: |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82304 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95307 |
||
| Host: | Target: | ||
| Build: | Known to work: | ||
| Known to fail: | Last reconfirmed: | 2025-01-22 00:00:00 | |
| Bug Depends on: | |||
| Bug Blocks: | 55004 | ||
|
Description
Darrell Wright
2019-11-07 18:00:25 UTC
sorry, posted incorrect CE link, but code below demonstrates it I see no regression, it has always been accepted by G++. Possibly a dup of Bug 82304. This particular cast, from const char array to const char pointer, is implicit so static_cast suffices (and the reinterpret_cast is implictly a static_cast). Editing your code sample to change reinterpret_cast to static_cast it is accepted without diagnostic on gcc, clang, msvc, icc https://gcc.godbolt.org/z/6a694c The final comment on the bug linked as a possible duplicate shows that some fixes were committed last month, fixing other cases. I guess this particular case can be closed. I mis-read this so was too hasty in suggesting "can be closed". The standard states that a expression evaluation fails to be a constant expression if it evaluates "reinterpret_cast" (i.e., by named token, not by the actual strength of cast required, so seems to be the intent). It's a 50/50 split with gcc & icc accepting, clang and msvc rejecting https://gcc.godbolt.org/z/drdT66 |