This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11748] New: g++ compiles invalid code


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]