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

            Bug ID: 92458
           Summary: Constraints do not work with precompiled headers
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
            Blocks: 67491
  Target Milestone: ---

// header, compile with g++ -std=gnu++2a -c
template<typename T> concept C = sizeof(T) > 1;
template<typename T> struct S { };
template<typename T> requires C<T> struct S<T> { };
template<typename T> requires (!C<T>) struct S<T> { };

// source file, compile with g++ -std=gnu++2a -c
#include "h.h"
S<int> s;


If no precompiled header exists, this compiles OK. If h.h.gch has been produced
by compiling the header with -std=gnu++2a -c then compiling the source file
gives an error:

h.cc:2:8: error: ambiguous template instantiation for 'struct S<int>'
    2 | S<int> s;
      |        ^
h.h:4:43: note: candidates are: 'template<class T> struct S<T> [with T = int]'
    4 | template<typename T> requires (!C<T>) struct S<T> { };
      |                                           ^~~~
h.h:5:46: note:                 'template<class T> struct S<T> [with T = int]'
h.cc:2:8: error: aggregate 'S<int> s' has incomplete type and cannot be defined
    2 | S<int> s;
      |        ^


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67491
[Bug 67491] [meta-bug] concepts issues

Reply via email to