[Bug c++/103700] New: Incomplete type not causing constraints to fail

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 14 00:01:46 GMT 2021


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

            Bug ID: 103700
           Summary: Incomplete type not causing constraints to fail
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

>From PR 101239:
Take:
    auto f(auto a) requires requires { a+1; } { return a+1; }
    auto f(auto a) { return a; }
    struct Incomplete *p;
    auto b = f(p);

----- CUT ----
The pointer addition in the first declaration of f should cause the constraint
to fail but currently we get a hard error instead:
<source>: In substitution of 'template<class auto:1> auto f(auto:1) requires
requires{a + 1;} [with auto:1 = Incomplete*]':
<source>:5:15:   required from here
<source>:2:41: error: invalid use of incomplete type 'struct Incomplete'
    2 |     auto f(auto a) requires requires { a+1; } { return a+1; }
      |                                        ~^~
<source>:4:12: note: forward declaration of 'struct Incomplete'
    4 |     struct Incomplete *p;
      |            ^~~~~~~~~~


More information about the Gcc-bugs mailing list