public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100313] New: pointer to member function is not const with sanitize=undefined
@ 2021-04-28  9:01 dushistov at mail dot ru
  2021-04-28 21:03 ` [Bug c++/100313] " mpolacek at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dushistov at mail dot ru @ 2021-04-28  9:01 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/100313] pointer to member function is not const with sanitize=undefined
  2021-04-28  9:01 [Bug c++/100313] New: pointer to member function is not const with sanitize=undefined dushistov at mail dot ru
@ 2021-04-28 21:03 ` mpolacek at gcc dot gnu.org
  2021-04-28 21:10 ` mpolacek at gcc dot gnu.org
  2021-04-28 21:16 ` mpolacek at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-04-28 21:03 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2021-04-28
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/100313] pointer to member function is not const with sanitize=undefined
  2021-04-28  9:01 [Bug c++/100313] New: pointer to member function is not const with sanitize=undefined dushistov at mail dot ru
  2021-04-28 21:03 ` [Bug c++/100313] " mpolacek at gcc dot gnu.org
@ 2021-04-28 21:10 ` mpolacek at gcc dot gnu.org
  2021-04-28 21:16 ` mpolacek at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-04-28 21:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Cleaned up:

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

struct S {
  inline void fn() { }
};

int main()
{
  Prop<&S::fn> prop;
  prop.notify();
}

Requires only -fsanitize=null.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/100313] pointer to member function is not const with sanitize=undefined
  2021-04-28  9:01 [Bug c++/100313] New: pointer to member function is not const with sanitize=undefined dushistov at mail dot ru
  2021-04-28 21:03 ` [Bug c++/100313] " mpolacek at gcc dot gnu.org
  2021-04-28 21:10 ` mpolacek at gcc dot gnu.org
@ 2021-04-28 21:16 ` mpolacek at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-04-28 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
In fact, this is about -fno-delete-null-pointer-checks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-28 21:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28  9:01 [Bug c++/100313] New: pointer to member function is not const with sanitize=undefined dushistov at mail dot ru
2021-04-28 21:03 ` [Bug c++/100313] " mpolacek at gcc dot gnu.org
2021-04-28 21:10 ` mpolacek at gcc dot gnu.org
2021-04-28 21:16 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).