------- Comment #2 from wilson at gcc dot gnu dot org 2005-10-12 23:22 ------- It isn't true that variable i and variable j have the same symbol name. The asm means that the symbol name of j will be "i" always. However, the symbol name of i will be the string "i" with various target dependent and command line option dependent transformations applied.
The easiest way to see this is to compile with -fleading-underscore and note that we now have two variables "i" and "_i", and there is no aliasing. -fleading-underscore is the default for some targets. Since these symbol name string transformations are applied late, when emitting assembly language, it currently isn't possible for the compiler to do anything useful here. Also, like most GCC extensions, no one probably considered the implications of what should happen with an input like this, so we can't really do much more than say that it is undefined, and that you can't expect any particular behaviour here. Ideally we should emit an error message, but it is probably not possible with current sources, and probably not worth the trouble to rewrite to make it possible. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24332