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

            Bug ID: 127595
           Summary: [ICE] internal compiler error: in verify_ctor_sanity,
                    at cp/constexpr.cc:7376 via brace initialization in
                    template
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: s103360021 at gmail dot com
  Target Milestone: ---

Compiling a template function that initializes a constexpr variable using brace
initialization combined with macro-guard parentheses (e.g.,
(std::numeric_limits<size_t>::max)()) causes an internal compiler error in GCC
17. This issue was originally encountered when building the Abseil library
(absl/strings/internal/str_join_internal.h).

Godbolt link: https://godbolt.org/z/Exj8dhMzb

## Minimal Reproducible Example

```C++
// mre.cpp
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <limits>

template <typename T>
void TriggerICE()
{
    // The extra parentheses around max() prevent macro expansion,
    // but combined with brace initialization in a template, it crashes GCC 17.
    constexpr uint64_t kMaxSize =
uint64_t{(std::numeric_limits<std::size_t>::max)()};

    // Cast to void to prevent unused variable warnings if it survives parsing
    (void)kMaxSize;
}

int main()
{
    TriggerICE<int>();

    return EXIT_SUCCESS;
}
```

Reply via email to