https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64870
Bug ID: 64870
Summary: value not set via reference
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: conradsand.arma at gmail dot com
Created attachment 34624
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34624&action=edit
rebug.cpp
gcc 4.9.2 fails to set a value through a reference.
Consider the following code:
#include <iostream>
struct blah {
inline double setval(unsigned int& x) const
{
x = 123;
return 456.0;
}
};
int
main(int argc, char** argv) {
blah blah_instance;
unsigned int val = 9999;
std::cout << blah_instance.setval(val) << " val: " << val << std::endl;
std::cout << blah_instance.setval(val) << " val: " << val << std::endl;
return 0;
}
when compiled with gcc 4.9.2, the above program produces the following output:
456 val: 9999
456 val: 123
when compiled with clang 3.5:
456 val: 123
456 val: 123