public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97050] New: ICE with segfault in lambda overload resolution
@ 2020-09-14 20:14 numerical.simulation at web dot de
  2020-09-14 20:16 ` [Bug c++/97050] " mpolacek at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: numerical.simulation at web dot de @ 2020-09-14 20:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97050
           Summary: ICE with segfault in lambda overload resolution
           Product: gcc
           Version: og10 (devel/omp/gcc-10)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: numerical.simulation at web dot de
  Target Milestone: ---

This issue can be observed in several varainst of gcc-trunk and 10.2.

--- 8< ---
#include <utility>
#include <type_traits>
#include <tuple>

// See
https://arne-mertz.de/2018/05/overload-build-a-variant-visitor-on-the-fly/

template <class ...Fs>
struct overload : Fs... {
  template <class ...Ts>
  overload(Ts&& ...ts) : Fs{std::forward<Ts>(ts)}...
  {} 

  using Fs::operator()...;
};

template <class ...Ts>
overload(Ts&&...) -> overload<std::remove_reference_t<Ts>...>;

struct get_operator {};
struct get_operands {};

struct plus {};

template<typename T1, typename T2> auto operator+(T1 const & t1, T2 const & t2)
{
    auto && operands_ = 
        [&](auto tag) 
        requires std::is_same_v<decltype(tag), get_operands> 
        {
             return std::make_tuple(t1, t2); 
        };  

    auto && operator_ = 
        [&](auto tag) 
        requires std::is_same_v<decltype(tag), get_operator>
        {
            return plus{};
        };

    return overload(operator_, operands_); 
}

int main() {
    struct A{}; struct B{}; struct C{};
    A a; B b; C c;

    auto sum = a + b + c;
    static_assert(std::is_same_v<decltype(sum(get_operator{})), plus>);
}
--- 8< ---


yields

<source>: In instantiation of 'operator+<overload<operator+<main()::A,
main()::B>::<lambda(auto:12)>, operator+<main()::A,
main()::B>::<lambda(auto:11)> >, main()::C>::<lambda(auto:11)> [with auto:11 =
get_operator]':

<source>:47:61:   required from here

<source>:47:61: internal compiler error: Segmentation fault

   47 |     static_assert(std::is_same_v<decltype(sum(get_operator{})), plus>);

      |                                                             ^

Please submit a full bug report


Weblink for quick check: 
https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAM1QDsCBlZAQwBtMQBGAFlICsupVs1qhkAUgBMAISnTSAZ0ztkBPHUqZa6AMKpWAVwC2tQVvQAZPLUwA5YwCNMxLgA5SAB1QLC62nsMTQS8fNTorG3sjJxdOdyUVMNoGAmZiAgDjU05FZUxVPxS0ggi7R2c3RVT0zKCchWqS6zLoiriASkVUA2JkDgByKQBma2RDLABqcSGdAzVWQgBPaexxAAYAQWHR8cwpmYJFj0wAfQJiZkIFFfWtyRHaMYNJ6Z0CAw92G83bgHpfiYMTB7BAEAgeBQgf5pGwAWiMzgIAC8AHRYX6SNZxX5rACsv1QADdnKxUMx0LCHAY8KwKcxYYS0ngRAQGXhQiRYXRYQQEJhYVRWItfrdbgRMEZPsxxfsdGNmAoFBMUSqAGLXIarTYNYgGVQTIkksnoCYgCbqlUoqYAdlkmwmE3FkuEMte8sVypVABUNVqNg7DcRSeSID6pAA2COelEEBTtU3m662hroEAgGjEADuaXQrzDmogsfa4mtABFLbcHSXZGWpj97RMDD5RIm06hjhciMQIO0K0M7Vsy9MB2KJVLXTN3UrLfm/YHg%2BhQ9dJJGV5b47CVgbiUHja8U2niBLDScj1RnFo%2Bmc876%2B6t%2B6Ltec9QQJsBMAQTu3nNKSDaa6Ww63DqL5vh%2BX4diI6BKtWJaAQ%2B9YbCB%2BqfE2/5wUBiFOuOmCvIcxy0MwCITF6OSOkcWhEXsXqSFuzBzKgBqQV2cihpwExoLQDRTCujpkTRHF0NxUYEJI8awQ2Dr0UQPGruGTE/toCgnPspZ1v6DqaVWuKyCu4i4qWEDSYxqTAOJklaRMR4AI7UkeSoHiA7InAoVEnISrxYGM%2BGYIWzBmaQYGft%2BFxKVulaWVWtoRZFllHu8xC0BMjlGMwADWpzvJ8vkEGRonFv26mxTa8HSFWiFacZslRiFv7ECp0xqTFln6bpkYGUZDGOv55kaZFNl2ZgDkEKmTnKa5CLuZ5%2BSsD5fkBUFEE/ixmrNVpEl9cVVkfj0SWoUmAGYZt61DghWwWfFu3bkaIa1V2JyBbVSknAVZWikOiHWK%2BqXWD26EWchr6DodhWAxMNYg2VYM6LBp0Dlp/rMMO4MTA4yM6BxR3NVVCjGKpEzMDxZUOETmNnVpDTSngyAnAqSjpBAjnORNpweTMXmzRRjPGNA4F3SQsOlu0nQTPtKyve9pb9J0rAgP0uL9KQpj9GsiuoHLMMyHIyXdL0ezDJwisEHLqvC6QaUgLiQwotaazWri1pxFiuLhuGuLuLL/TcIryuq6Q6v9IrkJrKQxsq9LpBwLAMCICgqCSjSzjkJQaAJ%2BwLjAJwaySKQVA0uKxCQhADgm4rDjWGkixy4bpCpwi9AAPK0EKpekFgqWiOwrf4EeBTEpC4ekJgAAe%2BRzAMNdfcorcLA4FzEIsehYNXRvEHgRgr50ND0EwbAcDw/CCMIogoHIchCHgDiQpAnTtkkA%2BwrCKaNRIWsyJiQd5AUGgQOYtTZEPbQpQogxGCN4XwdB/5gNCH4YB5RYi5ESIURoUD6hfySEUdIcDWgIMpjUfQWRBB4KaJEeBXBOgKF1n0chQg5YKyVq3AOw9XDhlhOGbgb5kDIAmFnFEkgJgQFwIQP8BtAp6DTs4HiQxODxk1rpaQRtS5mwtriEOntvakA3qohhg8A5BxACHMOptI4xwgEgbo4I5jJwgKnDwicEGYHwF2QQ29GAsC7gfTMFwPCb1ofLH2jC5YGwmJmQgCAJjMNYewzh3DeGSEUeHM2fJyQVB7H4jRWiQ6%2BzVnLfRhilGdAttwcMfCACckhuCSFcJwUprhuBDCGPUvxQwAm6NyaHApfj4k6L9nojpiTOg7h8BobgQA

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

* [Bug c++/97050] ICE with segfault in lambda overload resolution
  2020-09-14 20:14 [Bug c++/97050] New: ICE with segfault in lambda overload resolution numerical.simulation at web dot de
@ 2020-09-14 20:16 ` mpolacek at gcc dot gnu.org
  2020-09-14 20:37 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-14 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-09-14
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |mpolacek at gcc dot gnu.org
           Keywords|                            |ice-on-valid-code
            Version|og10 (devel/omp/gcc-10)     |11.0

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

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

* [Bug c++/97050] ICE with segfault in lambda overload resolution
  2020-09-14 20:14 [Bug c++/97050] New: ICE with segfault in lambda overload resolution numerical.simulation at web dot de
  2020-09-14 20:16 ` [Bug c++/97050] " mpolacek at gcc dot gnu.org
@ 2020-09-14 20:37 ` mpolacek at gcc dot gnu.org
  2021-10-01  9:54 ` pinskia at gcc dot gnu.org
  2021-10-01 18:12 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-14 20:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

namespace a {
template <typename d, typename e> constexpr bool f = __is_same_as(d, e);
}
struct g {};
struct h;
template <typename i, typename j> auto operator+(i, j) {
  auto k = [](auto l) requires a::f<decltype(l), g>{};
  return k;
}
void m() {
  struct n {
  } b;
  n c;
  auto o = b + c;
  a::f<decltype(o(g{})), h>;
}

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

* [Bug c++/97050] ICE with segfault in lambda overload resolution
  2020-09-14 20:14 [Bug c++/97050] New: ICE with segfault in lambda overload resolution numerical.simulation at web dot de
  2020-09-14 20:16 ` [Bug c++/97050] " mpolacek at gcc dot gnu.org
  2020-09-14 20:37 ` mpolacek at gcc dot gnu.org
@ 2021-10-01  9:54 ` pinskia at gcc dot gnu.org
  2021-10-01 18:12 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-01  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.3.0
      Known to work|                            |11.1.0

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks fixed in GCC 11.

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

* [Bug c++/97050] ICE with segfault in lambda overload resolution
  2020-09-14 20:14 [Bug c++/97050] New: ICE with segfault in lambda overload resolution numerical.simulation at web dot de
                   ` (2 preceding siblings ...)
  2021-10-01  9:54 ` pinskia at gcc dot gnu.org
@ 2021-10-01 18:12 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-01 18:12 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed in GCC 11+ by r11-8065.

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

end of thread, other threads:[~2021-10-01 18:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 20:14 [Bug c++/97050] New: ICE with segfault in lambda overload resolution numerical.simulation at web dot de
2020-09-14 20:16 ` [Bug c++/97050] " mpolacek at gcc dot gnu.org
2020-09-14 20:37 ` mpolacek at gcc dot gnu.org
2021-10-01  9:54 ` pinskia at gcc dot gnu.org
2021-10-01 18:12 ` ppalka 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).