This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/8488: invalid reference cast being accepted with -pedantic on
- From: bangerth at dealii dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, mrnobo1024 at yahoo dot com, nobody at gcc dot gnu dot org
- Date: 7 Nov 2002 15:13:29 -0000
- Subject: Re: c++/8488: invalid reference cast being accepted with -pedantic on
- Reply-to: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, mrnobo1024 at yahoo dot com, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
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