public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94333] New: internal compiler error: Segmentation fault ( when trying use structure binding in requires(requires{}))
@ 2020-03-25 18:10 dmusiienko at gmail dot com
  2020-03-26  8:33 ` [Bug c++/94333] " marxin at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dmusiienko at gmail dot com @ 2020-03-25 18:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94333
           Summary: internal compiler error: Segmentation fault ( when
                    trying use structure binding in requires(requires{}))
           Product: gcc
           Version: c++-concepts
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmusiienko at gmail dot com
  Target Milestone: ---

template <class T>
struct has2param
{
    typedef char yes;
    typedef struct{char n[2];} no;
    template <class U>
    static yes check(U u) requires(requires{[](auto u){auto [a, b] = u;}(u);});
    static no check(...);
    static constexpr bool y = sizeof(check(T())) == sizeof(yes);
};

struct point
{
    int x;
    int y;
};

int main()
{
    point p{1, 2};
    constexpr bool ans = has2param<decltype(p)>::y;
    return 0;
}

---------------------------------------
x86-64 gcc(trunc) compiler output:
---------------------------------------

<source>: In instantiation of 'static has2param<T>::yes has2param<T>::check(U)
requires requires{(<lambda>)(has2param<T>::check::u);} [with U = point; T =
point; has2param<T>::yes = char]':

<source>:9:43:   required from 'constexpr const bool has2param<point>::y'

<source>:21:50:   required from here

<source>:7:45: internal compiler error: Segmentation fault

    7 |     static yes check(U u) requires(requires{[](auto u){auto [a, b] =
u;}(u);});

      |                                            
^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Please submit a full bug report,

with preprocessed source if appropriate.

See <https://gcc.gnu.org/bugs/> for instructions.
-----------------------------------------------------

I expected an error, but not the one I received (compiler segf)

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

* [Bug c++/94333] internal compiler error: Segmentation fault ( when trying use structure binding in requires(requires{}))
  2020-03-25 18:10 [Bug c++/94333] New: internal compiler error: Segmentation fault ( when trying use structure binding in requires(requires{})) dmusiienko at gmail dot com
@ 2020-03-26  8:33 ` marxin at gcc dot gnu.org
  2021-08-08  9:00 ` [Bug c++/94333] ICE in tsubst_template_args at gcc/cp/pt.c:13074 " pinskia at gcc dot gnu.org
  2021-08-08  9:01 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-03-26  8:33 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-03-26
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r9-4045-g0c1e0d63fe0ceabb.
Before that it was rejected with:

pr94333.cc:7:45: error: lambda-expression in unevaluated context
    7 |     static yes check(U u) requires(requires{[](auto u){auto [a, b] =
u;}(u);});
      |                                             ^
pr94333.cc:7:76: error: expected ‘}’ before ‘;’ token
    7 |     static yes check(U u) requires(requires{[](auto u){auto [a, b] =
u;}(u);});
      |                                            ~                           
   ^
pr94333.cc:7:76: error: expected ‘)’ before ‘;’ token
    7 |     static yes check(U u) requires(requires{[](auto u){auto [a, b] =
u;}(u);});
      |                                   ~                                    
   ^
      |                                                                        
   )
pr94333.cc:7:78: error: expected ‘;’ before ‘)’ token
    7 |     static yes check(U u) requires(requires{[](auto u){auto [a, b] =
u;}(u);});
      |                                                                        
     ^
      |                                                                        
     ;
pr94333.cc:8:12: error: ‘no’ does not name a type
    8 |     static no check(...);
      |            ^~
pr94333.cc:9:44: error: ‘T’ was not declared in this scope
    9 |     static constexpr bool y = sizeof(check(T())) == sizeof(yes);
      |                                            ^
pr94333.cc:9:38: error: ‘check’ was not declared in this scope
    9 |     static constexpr bool y = sizeof(check(T())) == sizeof(yes);
      |                                      ^~~~~
pr94333.cc:9:60: error: ‘yes’ was not declared in this scope
    9 |     static constexpr bool y = sizeof(check(T())) == sizeof(yes);
      |                                                            ^~~
pr94333.cc:10:1: error: expected declaration before ‘}’ token
   10 | };
      | ^
pr94333.cc: In function ‘int main()’:
pr94333.cc:21:50: error: ‘y’ is not a member of ‘has2param<point>’
   21 |     constexpr bool ans = has2param<decltype(p)>::y;
      |                                                  ^

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

* [Bug c++/94333] ICE in tsubst_template_args at gcc/cp/pt.c:13074 ( when trying use structure binding in requires(requires{}))
  2020-03-25 18:10 [Bug c++/94333] New: internal compiler error: Segmentation fault ( when trying use structure binding in requires(requires{})) dmusiienko at gmail dot com
  2020-03-26  8:33 ` [Bug c++/94333] " marxin at gcc dot gnu.org
@ 2021-08-08  9:00 ` pinskia at gcc dot gnu.org
  2021-08-08  9:01 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-08  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #1)
> Confirmed, started with r9-4045-g0c1e0d63fe0ceabb.
> Before that it was rejected with:
> 
> pr94333.cc:7:45: error: lambda-expression in unevaluated context
>     7 |     static yes check(U u) requires(requires{[](auto u){auto [a, b] =
> u;}(u);});

Right because the lambda-expression in unevaluated context feature was not
supported before that patch :).

This code is valid and works with GCC 10.2.0 and 11+.

Note clang trunk ICEs on it.

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

* [Bug c++/94333] ICE in tsubst_template_args at gcc/cp/pt.c:13074 ( when trying use structure binding in requires(requires{}))
  2020-03-25 18:10 [Bug c++/94333] New: internal compiler error: Segmentation fault ( when trying use structure binding in requires(requires{})) dmusiienko at gmail dot com
  2020-03-26  8:33 ` [Bug c++/94333] " marxin at gcc dot gnu.org
  2021-08-08  9:00 ` [Bug c++/94333] ICE in tsubst_template_args at gcc/cp/pt.c:13074 " pinskia at gcc dot gnu.org
@ 2021-08-08  9:01 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-08  9:01 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 94128.

*** This bug has been marked as a duplicate of bug 94128 ***

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

end of thread, other threads:[~2021-08-08  9:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 18:10 [Bug c++/94333] New: internal compiler error: Segmentation fault ( when trying use structure binding in requires(requires{})) dmusiienko at gmail dot com
2020-03-26  8:33 ` [Bug c++/94333] " marxin at gcc dot gnu.org
2021-08-08  9:00 ` [Bug c++/94333] ICE in tsubst_template_args at gcc/cp/pt.c:13074 " pinskia at gcc dot gnu.org
2021-08-08  9:01 ` 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).