[gnu.gcc.bug] Volatile asm's reordered

tdw%computer-lab.cambridge.ac.uk@NSFNET-RELAY.AC.UK (Tim Wilson) (10/24/89)

The following script contains (working through the checklist):
 * The version of GCC
 * The complete input file
 * The command arguments
----------------------------------------------------------------------
~/rvd/c/sys/test $ cat bug.i
main ()
{
    int old = ({int a;
		asm volatile ("first":"=g" (a));
		a;});
    asm volatile ("second");
    use(old);
}
~/rvd/c/sys/test $ gcc68k -v -O -S bug.i
gcc version 1.35
 /usr/users/tdw/gcc68k/bin/gcc68k-cc1 bug.i -quiet -O -version -o bug.s
GNU C version 1.35 (68k, MIT syntax) compiled by GNU C version 1.30.
~/rvd/c/sys/test $ cat bug.s
#NO_APP
gcc_compiled.:
.text
	.even
.globl _main
_main:
	link a6,#0
#APP
	second
	first
#NO_APP
	jbsr _use
	unlk a6
	rts
~/rvd/c/sys/test $ 
----------------------------------------------------------------------
 * The names of the files I used for tm.h and md
   - tm.h -> config/tm-sun3.h
   - md -> config/m68k.md
 * The type of machine, op sys, version number
   - VaxStation running Ultrix 1.2
 * A description of what I believe to be incorrect
   - I believe the variable `old' should have acquired its value
     from `asm volatile("first")' before `asm volatile("second")' 
     is executed.  However, the assember output reveals that
     the two asm volatiles have been reordered.

     In my real code "first" and "second" contain side-effects
     which are order-dependant.  Gcc does not know about 
     these---hence the `volatile's, which seem to be ignored.

Tim Wilson	University of Cambridge Computer Laboratory, 
		New Museums Site, Pembroke Street, CAMBRIDGE, CB2 3QG, UK.
Tel:   +44 223 334624		Internet: tdw%cl.cam.ac.uk@nsfnet-relay.ac.uk
Janet: tdw@uk.ac.cam.cl		Uucp:     ...!uunet!mcvax!ukc!cam-cl!tdw