https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125805

            Bug ID: 125805
           Summary: GCC rejects valid program involving comparison of
                    address to two distinct objects of incomplete type
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following valid program is rejected by gcc but accepted by both clang and
msvc. https://godbolt.org/z/fsesoEb63
```
struct A;

extern const A a1;
extern const A a2;

static_assert(&a1 != &a2);
```

GCC says:
```
<source>:6:19: error: non-constant condition for static assertion
    6 | static_assert(&a1 != &a2);
      |               ~~~~^~~~~~
<source>:6:19: error: '((& a1) != (& a2))' is not a constant expression
Compiler returned: 1
```

Reply via email to