c++/8488: invalid reference cast being accepted with -pedantic on

bangerth@dealii.org bangerth@dealii.org
Thu Nov 7 07:13:00 GMT 2002


Synopsis: invalid reference cast being accepted with -pedantic on

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Thu Nov  7 07:13:28 2002
State-Changed-Why:
    Very interesting. Indeed, this
        (int &)3 = 2;
    compiles into this:
       	movl $3,-4(%ebp)
    	leal -4(%ebp),%edx
    	movl $2,(%edx)
    (Sure, after all, the code said: "take the address of the
    3, and write a 2 into that place").
    
    
    As an aside, from hearsay, some Fortran compilers allowed
    you to do this:
          subroutine f(i)
          i = 2
          end
    
          subroutine g
          call f(1)
          write (*) 1
          end
    
    If you were unlucky, and the compiler chose to use the same
    address for the two ones in g(), then you'd get a "2" onto
    your screen, though you wrote "write (*) 1".

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8488



More information about the Gcc-bugs mailing list