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

            Bug ID: 100828
           Summary: Arbitrary limit on constraint complexity
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matthewjbarichello at gmail dot com
  Target Milestone: ---

Created attachment 50889
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50889&action=edit
Patch to remove the constraint complexity limit from gcc-11.1.0

It would seem that there is an arbitrary limit on the complexity of constraints
in gcc 11.

    #define a (0 || 0 && 0)

    namespace e {
     template<typename>
     struct f;
    }
    template<typename g>
    concept f = e::f<g>::h && true && a;

    template<typename>
    concept i = a && a;

    template <typename, typename j>
    requires(i<j> || f<j>)
    struct k;

    template<typename g, typename j>
    requires(i<j> && i<g>)
    struct k<g, j>;

This example, reduced with c-reduce, yields:

    <source>:19:8: error: ‘0 \/ 0 /\ 0 /\ 0 \/ 0 /\ 0 \/ e::f<
<template-parameter-1-1> >::h [with g = j] /\ true /\ 0 \/ 0 /\ 0’ exceeds the
maximum constraint complexity
       19 | struct k<g, j>;
          |        ^~~~~~~

Attached is a patch for gcc, as of the releases/gcc-11.1.0 tag, which allows
gcc to compile the example without an issue.

Clang does not seem to have this limitation and has no problem compiling the
example. Is there a reason for this limit?

Reply via email to