public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/62285] New: const reference binding to temporary when using -fPIC
@ 2014-08-27 14:41 rpzatkoff at gmail dot com
2014-08-27 15:33 ` [Bug c++/62285] " redi at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: rpzatkoff at gmail dot com @ 2014-08-27 14:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62285
Bug ID: 62285
Summary: const reference binding to temporary when using -fPIC
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rpzatkoff at gmail dot com
I found an issue with a simple program when using a const reference in C++.
I have compiled this with various versions of g++ with different flags and get
different results in many of them.
I am running on an Intel Xeon processor
------------------------------
#include <iostream>
int64_t foo()
{
return 5;
}
int main( int, char** )
{
int64_t biggerNum = 5000;
const int64_t& minimum = std::min( foo(), biggerNum );
std::cout << minimum << std::endl;
return 0;
}
------------------------------
The -fPIC flag changes the results of the program and in different
optimizations will produce 5000 or 0 instead of 5. gcc-4.9.1 is the latest I
have reproduced the problem - and it does not appear to affect clang.
------------
*** GCC 4.4.7 ***
-g3 -O0 -std=c++0x
gcc-4.4.7 -g3 -O0 -std=c++0x
5
-g3 -O1 -std=c++0x
gcc-4.4.7 -g3 -O1 -std=c++0x
5
-g3 -O2 -std=c++0x
gcc-4.4.7 -g3 -O2 -std=c++0x
5
-g3 -O3 -std=c++0x
gcc-4.4.7 -g3 -O3 -std=c++0x
5
-g3 -O0 -std=c++0x
gcc-4.4.7 -g3 -O0 -std=c++0x -fPIC
5
-g3 -O1 -std=c++0x
gcc-4.4.7 -g3 -O1 -std=c++0x -fPIC
5
-g3 -O2 -std=c++0x
gcc-4.4.7 -g3 -O2 -std=c++0x -fPIC
5
-g3 -O3 -std=c++0x
gcc-4.4.7 -g3 -O3 -std=c++0x -fPIC
5
*** GCC 4.7.3 ***
-g3 -O0 -std=c++11
gcc-4.7.3 -g3 -O0 -std=c++11
5
-g3 -O1 -std=c++11
gcc-4.7.3 -g3 -O1 -std=c++11
0
-g3 -O2 -std=c++11
gcc-4.7.3 -g3 -O2 -std=c++11
5
-g3 -O3 -std=c++11
gcc-4.7.3 -g3 -O3 -std=c++11
5
-g3 -O0 -std=c++11
gcc-4.7.3 -g3 -O0 -std=c++11 -fPIC
5
-g3 -O1 -std=c++11
gcc-4.7.3 -g3 -O1 -std=c++11 -fPIC
0
-g3 -O2 -std=c++11
gcc-4.7.3 -g3 -O2 -std=c++11 -fPIC
5000
-g3 -O3 -std=c++11
gcc-4.7.3 -g3 -O3 -std=c++11 -fPIC
5000
*** GCC 4.8.2 ***
-g3 -O0 -std=c++11
gcc-4.8.2 -g3 -O0 -std=c++11
5
-g3 -O1 -std=c++11
gcc-4.8.2 -g3 -O1 -std=c++11
5
-g3 -O2 -std=c++11
gcc-4.8.2 -g3 -O2 -std=c++11
5
-g3 -O3 -std=c++11
gcc-4.8.2 -g3 -O3 -std=c++11
5
-g3 -O0 -std=c++11
gcc-4.8.2 -g3 -O0 -std=c++11 -fPIC
5
-g3 -O1 -std=c++11
gcc-4.8.2 -g3 -O1 -std=c++11 -fPIC
0
-g3 -O2 -std=c++11
gcc-4.8.2 -g3 -O2 -std=c++11 -fPIC
5000
-g3 -O3 -std=c++11
gcc-4.8.2 -g3 -O3 -std=c++11 -fPIC
5000
*** GCC 4.9.0 ***
-g3 -O0 -std=c++11
gcc-4.9.0 -g3 -O0 -std=c++11
5
-g3 -O1 -std=c++11
gcc-4.9.0 -g3 -O1 -std=c++11
5
-g3 -O2 -std=c++11
gcc-4.9.0 -g3 -O2 -std=c++11
5
-g3 -O3 -std=c++11
gcc-4.9.0 -g3 -O3 -std=c++11
5
-g3 -O0 -std=c++11
gcc-4.9.0 -g3 -O0 -std=c++11 -fPIC
5
-g3 -O1 -std=c++11
gcc-4.9.0 -g3 -O1 -std=c++11 -fPIC
0
-g3 -O2 -std=c++11
gcc-4.9.0 -g3 -O2 -std=c++11 -fPIC
5000
-g3 -O3 -std=c++11
gcc-4.9.0 -g3 -O3 -std=c++11 -fPIC
5000
*** GCC 4.9.1 ***
-g3 -O0 -std=c++11
gcc-4.9.1 -g3 -O0 -std=c++11
5
-g3 -O1 -std=c++11
gcc-4.9.1 -g3 -O1 -std=c++11
5
-g3 -O2 -std=c++11
gcc-4.9.1 -g3 -O2 -std=c++11
5
-g3 -O3 -std=c++11
gcc-4.9.1 -g3 -O3 -std=c++11
5
-g3 -O0 -std=c++11
gcc-4.9.1 -g3 -O0 -std=c++11 -fPIC
5
-g3 -O1 -std=c++11
gcc-4.9.1 -g3 -O1 -std=c++11 -fPIC
0
-g3 -O2 -std=c++11
gcc-4.9.1 -g3 -O2 -std=c++11 -fPIC
5000
-g3 -O3 -std=c++11
gcc-4.9.1 -g3 -O3 -std=c++11 -fPIC
5000
*** Clang 3.4 ***
-g3 -O0 -std=c++11
clang-3.4 -g3 -O0 -std=c++11
5
-g3 -O1 -std=c++11
clang-3.4 -g3 -O1 -std=c++11
5
-g3 -O2 -std=c++11
clang-3.4 -g3 -O2 -std=c++11
5
-g3 -O3 -std=c++11
clang-3.4 -g3 -O3 -std=c++11
5
-g3 -O0 -std=c++11
clang-3.4 -g3 -O0 -std=c++11 -fPIC
5
-g3 -O1 -std=c++11
clang-3.4 -g3 -O1 -std=c++11 -fPIC
5
-g3 -O2 -std=c++11
clang-3.4 -g3 -O2 -std=c++11 -fPIC
5
-g3 -O3 -std=c++11
clang-3.4 -g3 -O3 -std=c++11 -fPIC
5
-------
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-27 16:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-27 14:41 [Bug c++/62285] New: const reference binding to temporary when using -fPIC rpzatkoff at gmail dot com
2014-08-27 15:33 ` [Bug c++/62285] " redi at gcc dot gnu.org
2014-08-27 15:41 ` redi at gcc dot gnu.org
2014-08-27 16:05 ` rpzatkoff at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).