[Bug c++/124244] New: [reflection] maybe bogus -Wtautological-compare warning
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Feb 25 18:21:49 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124244
Bug ID: 124244
Summary: [reflection] maybe bogus -Wtautological-compare
warning
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
```
#include <meta>
static constexpr std::pair<int, short> p = {1, 2};
static_assert (&[:std::meta::reflect_object (p.first):] == &p.first);
```
compiles fine, but we emit:
w.C:3:57: warning: self-comparison always evaluates to true
[-Wtautological-compare]
3 | static_assert (&[:std::meta::reflect_object (p.first):] == &p.first);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~~~~~~~
Sure, let's warn for "&p.first == &p.first", but the warning above looks
questionable.
More information about the Gcc-bugs
mailing list