Bug 109975 - error: '(((int*)(&<anonymous>.X::a)) != 0)' is not a constant expression
Summary: error: '(((int*)(&<anonymous>.X::a)) != 0)' is not a constant expression
Status: RESOLVED DUPLICATE of bug 85944
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2023-05-26 03:12 UTC by Ed Catmur
Modified: 2023-05-26 03:14 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Catmur 2023-05-26 03:12:01 UTC
struct X { int a[1]; };
constexpr bool b = (X{}.a != 0);

<source>:7:27: error: '(((int*)(&<anonymous>.X::a)) != 0)' is not a constant expression
    7 | constexpr bool b = (X{}.a != 0);
      |                    ~~~~~~~^~~~~

AFAICT this does not fall foul of anything in [expr.const]. Other compilers accept, with a tautological-compare warning in the case of clang.
Similar to bug 71962, but this happens without enabling sanitizer.
Comment 1 Drea Pinski 2023-05-26 03:14:42 UTC
Dup of bug 85944.

*** This bug has been marked as a duplicate of bug 85944 ***