]> gcc.gnu.org Git - gcc.git/commit
varasm: check float size [PR109359]
authorJason Merrill <jason@redhat.com>
Thu, 1 Jun 2023 18:41:07 +0000 (14:41 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 5 Feb 2024 22:25:13 +0000 (17:25 -0500)
commit9b8e82ab45d1ad976a824cfd7c9bd2640c8bc8e3
treedb25d1305afbf99ac3d07ac2d03bdd8b99fee68b
parent8b8e09c19045c30a1d4f63fd3ea0445660475d35
varasm: check float size [PR109359]

In PR95226, the testcase was failing because we tried to output_constant a
NOP_EXPR to float from a double REAL_CST, and so we output a double where
the caller wanted a float.  That doesn't happen anymore, but with the
output_constant hunk we will ICE in that situation rather than emit the
wrong number of bytes.

Part of the problem was that initializer_constant_valid_p_1 returned true
for that NOP_EXPR, because it compared the sizes of integer types but not
floating-point types.  So the C++ front end assumed it didn't need to fold
the initializer.

This also fixed the test for PR109359.

PR c++/95226
PR c++/109359

gcc/ChangeLog:

* varasm.cc (output_constant) [REAL_TYPE]: Check that sizes match.
(initializer_constant_valid_p_1): Compare float precision.

gcc/testsuite/ChangeLog:

* g++.dg/ext/frounding-math1.C: New test.

(cherry picked from commit e7cc4d703bceb9095316c106eba0d1939c6c8044)
gcc/testsuite/g++.dg/ext/frounding-math1.C [new file with mode: 0644]
gcc/varasm.cc
This page took 0.055148 seconds and 5 git commands to generate.