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]

optimization/5366: asm code produces an error without -O but is ok with -O



>Number:         5366
>Category:       optimization
>Synopsis:       asm code produces an error without -O but is ok with -O
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 12 16:36:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Eric Lesage
>Release:        3.0.1 20010716 (prerelease) and others (3.0.3, etc. see below).
>Organization:
>Environment:
System: Linux delta 2.4.17 #1 Tue Jan 8 21:02:30 EST 2002 i686 unknown
Architecture: i686

host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /home/eric/gcc/gcc-cvs-3.0/configure --prefix=/usr/local/gcc-3.0 --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ --enable-long-long
>Description:
	Also tested with gcc 3.0.3, gcc 2.96-85, egcs 1.1.2,
	gcc 2.95.4 20010319 (prerelease) and gcc 3.1 20011112 (experimental)
	on similar environments (Linux 2.4 i686-pc-linux-gnu).
	
	The attached test case compiles ok if gcc is passed -O or -O2.
	It does not compile otherwise. The problem happens to occur in
	the glibc 2.2.4 pthread spinlock code. The attached test case is
	enough to reproduce the problem (and much smaller).
	The problem I'm reporting is the inconsistency: the code is either
	valid or not (I expect it is valid), but that shouldn't be a
	function of the optimization level.
>How-To-Repeat:
	-- begin test case --
	struct _pthread_fastlock
	{
	  long int __status;
	  int __spinlock;
	};
	
	void __pthread_lock(struct _pthread_fastlock * lock)
	{
	   __asm __volatile ("" : "=m" (lock->__status) : "0" (lock->__status));
	}
	-- end test case --
	
	Compiling the test case with gcc -v -c -o test.o gcctest.c gives:
	
	Reading specs from /usr/local/gcc-3.0/lib/gcc-lib/i686-pc-linux-gnu/3.0.1/specs
	Configured with: /home/eric/gcc/gcc-cvs-3.0/configure --prefix=/usr/local/gcc-3.0 --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ --enable-long-long
	Thread model: single
	gcc version 3.0.1 20010716 (prerelease)
	 /usr/local/gcc-3.0/lib/gcc-lib/i686-pc-linux-gnu/3.0.1/cc1 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=1 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ gcctest.c -quiet -dumpbase gcctest.c -version -o /tmp/ccdpAEFi.s
	GNU CPP version 3.0.1 20010716 (prerelease) (cpplib) (i386 Linux/ELF)
	GNU C version 3.0.1 20010716 (prerelease) (i686-pc-linux-gnu)
	         compiled by GNU C version 3.0.1 20010716 (prerelease).
	
	ignoring duplicate directory "/usr/local/include"
	#include "..." search starts here:
	#include <...> search starts here:
	/usr/local/include
	/usr/local/ssl/include
	/usr/local/include/kerberosIV
	/usr/local/pgsql/include
	/usr/local/schily/include
	/usr/local/gcc-3.0/lib/gcc-lib/i686-pc-linux-gnu/3.0.1/include
	/usr/local/gcc-3.0/i686-pc-linux-gnu/include
	/usr/include
	End of search list.
	gcctest.c: In function `__pthread_lock':
	gcctest.c:9: inconsistent operand constraints in an `asm'


	Compilation with -O succeeds.

>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:


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