This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11748] New: g++ compiles invalid code
- From: "markus dot breuer at materna dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Jul 2003 14:40:58 -0000
- Subject: [Bug c++/11748] New: g++ compiles invalid code
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11748
Summary: g++ compiles invalid code
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: markus dot breuer at materna dot de
CC: gcc-bugs at gcc dot gnu dot org
g++ compiles invalid code without any warning. The code sample looks like
following:
void foo( unsigned short& _value )
{
_value = 10;
}
int main()
{
int val=0;
// create temporary object by casting
// and bind temporary to non-const reference
foo( static_cast<unsigned short>(val) );
}
Temporary objects are allowed to be bound to const references only. The code
above was compiled with option -Wall and -pedantic, but there was no warning
or error output.
In my opinion the code is only valid, if foo is defined as void foo( const
unsigned short&).
The generated executeble won't work correctly.