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

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Relatedly, if we actually make x constexpr

#include <vector>
const std::size_t N = 1'000'000;
constexpr std::vector<int> x(N);
int main() {}

we end up evaluating its expensive initialization (and hitting the constexpr
loop/ops limit) four times:

1. expand_default_init -> maybe_constant_init
2. store_init_value -> maybe_constant_value
3. store_init_value -> maybe_constant_init
4. store_init_value -> cxx_constant_init

The first three silently fail due to hitting the ops limit, and the fourth
actually diagnoses the failure.  This seems wasteful, we should silently
evaluate such an initializer once.

For the original testcase where x is not constexpr, we constant evaluate the
initialization just once (which silently fails due to the ops limit), which
still takes a few seconds unfortunately.

Reply via email to