[Bug c++/90757] New: inlining skips function parameter initialization
jens.georg at desy dot de
gcc-bugzilla@gcc.gnu.org
Wed Jun 5 13:25:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90757
Bug ID: 90757
Summary: inlining skips function parameter initialization
Product: gcc
Version: 9.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jens.georg at desy dot de
Target Milestone: ---
Created attachment 46454
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46454&action=edit
sample code showing inlining issue
When compiling the attached code with -O3 -Wuninitialized, we get the following
warning:
msk_jenkins@3db9ec2f15ea:~$ g++ -std=c++17 -O3 -Wuninitialized
aliasing_inlining.cc
aliasing_inlining.cc: In function 'int main()':
aliasing_inlining.cc:8:15: warning: 'raw' is used uninitialized in this
function [-Wuninitialized]
8 | float genericRepresentation = *(reinterpret_cast<const
float*>(&(*it)));
| ^~~~~~~~~~~~~~~~~~~~~
aliasing_inlining.cc:15:5: note: 'raw' was declared here
15 | int main()
| ^~~~
And running the code will result in "0"
msk_jenkins@3db9ec2f15ea:~$ ./a.out
0
With -fno-inline-small-functions, the code returns 3.25 as expected:
msk_jenkins@3db9ec2f15ea:~$ g++ -std=c++17 -O3 -Wuninitialized
aliasing_inlining.cc -fno-inline-small-functions
msk_jenkins@3db9ec2f15ea:~$ ./a.out
3.25
The code compiles and runs also fine if the for loop is omitted.
The code is a stripped down version of out template code that is also supposed
to handle STL containers and iterators, therefore there's a lot of probably
unnessary indirection in there.
It compiles fine on GCC 5.4, 7.1 and 8.1
GCC is from SUSE tumbleweed:
msk_jenkins@3db9ec2f15ea:~$ gcc --version
gcc (SUSE Linux) 9.1.1 20190520 [gcc-9-branch revision 271396]
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
More information about the Gcc-bugs
mailing list