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

            Bug ID: 100313
           Summary: pointer to member function is not const with
                    sanitize=undefined
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dushistov at mail dot ru
  Target Milestone: ---

Here simple example extracted from Qt 6 git:

```
template<auto Signal=nullptr>
struct Prop {
    void notify()
    {
            if constexpr (Signal != nullptr) {
            }
    }
};

class QObjectPrivate {
public:
    struct ExtraData
    {
            inline void nameChangedForwarder()  {}
    };
};

int main()
{
        Prop<&QObjectPrivate::ExtraData::nameChangedForwarder>  prop;
        prop.notify();
}

```

"g++ -std=c++17" compiles it just fine,
while "g++ -std=c++17 -fsanitize=undefined" gitves such error:

test2.cpp: In instantiation of 'void Prop<Signal>::notify() [with auto Signal =
&QObjectPrivate::ExtraData::nameChangedForwarder]':
test2.cpp:21:13:   required from here
test2.cpp:5:34: error: '(QObjectPrivate::ExtraData::nameChangedForwarder != 0)'
is not a constant expression
    5 |             if constexpr (Signal != nullptr) {
      |                           ~~~~~~~^~~~~~~~~~


This is with gcc 11.1.0 .

Intialy reported as part of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67762
,
but I look at initial testcase for 67762 and it looks like completely
unrelated.

Reply via email to