public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114962] New: For each iteration in static assert fails to compile
@ 2024-05-06 16:01 jdapena at igalia dot com
  2024-05-06 16:16 ` [Bug c++/114962] For each iteration in static assert fails to compile with pointer to member functions pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jdapena at igalia dot com @ 2024-05-06 16:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114962
           Summary: For each iteration in static assert fails to compile
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jdapena at igalia dot com
  Target Milestone: ---

Created attachment 58109
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58109&action=edit
Test case

The attached example, that allows to make sure all members are defined in a
constexpr created std::array, fails in GCC (and works in Clang at least from
version 10.x and in current trunk).

I am not sure if this is a valid pattern, so reporting a bug to GCC for further
analysis.

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

* [Bug c++/114962] For each iteration in static assert fails to compile with pointer to member functions
  2024-05-06 16:01 [Bug c++/114962] New: For each iteration in static assert fails to compile jdapena at igalia dot com
@ 2024-05-06 16:16 ` pinskia at gcc dot gnu.org
  2024-05-06 16:27 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-06 16:16 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-05-06

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, This looks like another "pointer to member function" issue (I
changed the array to being int and it works).

If we move the static assert/lamdba outside of the class, it works; so it looks
like maybe (non-)complete class context issue going on here.

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

* [Bug c++/114962] For each iteration in static assert fails to compile with pointer to member functions
  2024-05-06 16:01 [Bug c++/114962] New: For each iteration in static assert fails to compile jdapena at igalia dot com
  2024-05-06 16:16 ` [Bug c++/114962] For each iteration in static assert fails to compile with pointer to member functions pinskia at gcc dot gnu.org
@ 2024-05-06 16:27 ` mpolacek at gcc dot gnu.org
  2024-05-06 18:36 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-05-06 16:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I agree; seems valid to me.

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

* [Bug c++/114962] For each iteration in static assert fails to compile with pointer to member functions
  2024-05-06 16:01 [Bug c++/114962] New: For each iteration in static assert fails to compile jdapena at igalia dot com
  2024-05-06 16:16 ` [Bug c++/114962] For each iteration in static assert fails to compile with pointer to member functions pinskia at gcc dot gnu.org
  2024-05-06 16:27 ` mpolacek at gcc dot gnu.org
@ 2024-05-06 18:36 ` mpolacek at gcc dot gnu.org
  2024-05-06 18:43 ` pinskia at gcc dot gnu.org
  2024-05-06 18:44 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-05-06 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-reduction             |

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
// PR c++/114962

template <typename _Tp, int _Nm> struct __array_traits {
  using _Type = _Tp[_Nm];
};
template <typename _Tp, int _Nm> struct array {
  typedef _Tp value_type;
  typedef value_type *const_iterator;
  __array_traits<_Tp, _Nm>::_Type _M_elems;
  constexpr const_iterator begin() const { return const_iterator(_M_elems); }
  constexpr const_iterator end() const { return const_iterator(); }
  constexpr value_type &operator[](long __n) { return _M_elems[__n]; }
};
struct A {
  void third();
  static constexpr array kArray = [] {
    array<void (A::*)(), 3> a;
    a[0] = a[1] = a[2] = &A::third;
    return a;
  }();
  static_assert([] {
    for (auto item : kArray)
      if (item)
        return true;
    return false;
  }(), "");
};

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

* [Bug c++/114962] For each iteration in static assert fails to compile with pointer to member functions
  2024-05-06 16:01 [Bug c++/114962] New: For each iteration in static assert fails to compile jdapena at igalia dot com
                   ` (2 preceding siblings ...)
  2024-05-06 18:36 ` mpolacek at gcc dot gnu.org
@ 2024-05-06 18:43 ` pinskia at gcc dot gnu.org
  2024-05-06 18:44 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-06 18:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #3)
> // PR c++/114962

Reduced much further and even removing the for loop and the array:
```
struct A {
  void third();
  using Handler = void (A::*)();
  static constexpr Handler kArray = &A::third;
  static_assert([] {
        return (kArray)!=nullptr;
  }(), "");
};
```

Which does point to a Pointer to member function issue.

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

* [Bug c++/114962] For each iteration in static assert fails to compile with pointer to member functions
  2024-05-06 16:01 [Bug c++/114962] New: For each iteration in static assert fails to compile jdapena at igalia dot com
                   ` (3 preceding siblings ...)
  2024-05-06 18:43 ` pinskia at gcc dot gnu.org
@ 2024-05-06 18:44 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-06 18:44 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=114031

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Which points to a very similar issue of PR 114031.

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

end of thread, other threads:[~2024-05-06 18:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06 16:01 [Bug c++/114962] New: For each iteration in static assert fails to compile jdapena at igalia dot com
2024-05-06 16:16 ` [Bug c++/114962] For each iteration in static assert fails to compile with pointer to member functions pinskia at gcc dot gnu.org
2024-05-06 16:27 ` mpolacek at gcc dot gnu.org
2024-05-06 18:36 ` mpolacek at gcc dot gnu.org
2024-05-06 18:43 ` pinskia at gcc dot gnu.org
2024-05-06 18:44 ` pinskia 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).