]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: ICE with operator new[] in constexpr [PR118775]
authorMarek Polacek <polacek@redhat.com>
Tue, 11 Feb 2025 20:43:40 +0000 (15:43 -0500)
committerMarek Polacek <polacek@redhat.com>
Fri, 7 Mar 2025 17:40:20 +0000 (12:40 -0500)
commitaa55a6a30bc4778938af42dac9b624cf67fa4698
treed6266968813bce62f5dec6584de81651b1d37f1f
parentc781da2c10641a651019f8fe77f57ccdbc49f024
c++: ICE with operator new[] in constexpr [PR118775]

Here we ICE since r11-7740 because we no longer say that (long)&a
(where a is a global var) is non_constant_p.  So VERIFY_CONSTANT
does not return and we crash on tree_to_uhwi.  We should check
tree_fits_uhwi_p before calling tree_to_uhwi.

PR c++/118775

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_call_expression): Check tree_fits_uhwi_p.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constexpr-new24.C: New test.
* g++.dg/cpp2a/constexpr-new25.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/constexpr.cc
gcc/testsuite/g++.dg/cpp2a/constexpr-new24.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-new25.C [new file with mode: 0644]