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

            Bug ID: 102748
           Summary: static_assert on concept leads to undefined reference
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: raffael at casagrande dot ch
  Target Milestone: ---

Try to compile and link the following simple program with `-std=c++20`:
-----------------------------------
template <class RANGE, class CALLABLE>
auto ForEachGuided(RANGE&& range, CALLABLE&& c) {
  range.begin();
}

struct RandomAccessRangeAT {
  void begin() const noexcept;
};

template <class FE_SPACE_FACTORY>
concept FESpaceFactory = requires(const FE_SPACE_FACTORY& fe_space_factory,
                                  const RandomAccessRangeAT& range) {
  {fe_space_factory(range)};
};

int main() {
  auto fes_provider = [](auto&& range) {
    ForEachGuided(range, []() {});
  };
  static_assert(FESpaceFactory<decltype(fes_provider)>);
}
--------------------------------------

Compilation will work, but during linking we get the error message:
"undefined reference to `RandomAccessRangeAT::begin() const'"

As soon as we apply some optimization flags, the linking error vanishes.
Also clang doesn't have this problem...
  • [Bug c++/102748] New: static_ass... raffael at casagrande dot ch via Gcc-bugs

Reply via email to