sprintf core dumps compiling with gcc 2.95 for ultrasparc

Phil Lu lu@arlut.utexas.edu
Thu Mar 9 14:31:00 GMT 2000


//sprintf core dumps compiling with gcc 2.95 for ultrasparc with:

//	g++ -v --save-temps -mcpu=v9 -Wa,-xarch=v8plusa main.cc

//This little snippet core dumps for gcc 2.95 but not for 2.8.1

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
	// ---- Test sprintf bug compiled for ultrasparc
		printf("Checking to see if compiler has core dump problem ...\n");
		printf("  It happens with gcc 2.95+ 'g++ -v --save-temps -mcpu=v9 \
 -Wa,-xarch=v8plusa'.\n");

		float v=0;
		char buf[1024];

		//#define MAKE_COMPILER_BUG_GO_AWAY
	  	#if defined(MAKE_COMPILER_BUG_GO_AWAY)
			sprintf(buf, "%%07.3f", v);
	  	#endif
		
		sprintf(buf, "%d%d%d%d%d%d%f", 1,1,1,1,1,1,v);

		printf("**** GOOD ... Did not core dump due to sprintf()!\n");
	// ---- End of bug testing

    return 0;
}

Thanks,
Phil.
-------  Phil Lu  ------- =|||---------|||= ----- Sys Admin/Developer
On Site: Applied Research Laboratories          * Work:  512.835.3480
         The University of Texas at Austin        FAX:   512.835.3259
Mail To: PO Box 8029,      Austin, TX 78713        
Ship To: 10000 Burnet Rd., Austin, TX 78758       lu@arlut.utexas.edu
bug-sprintf-2.95.tgz
bug-sprintf-2.8.1.tgz

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug-sprintf-2.8.1.tgz
Type: application/x-gzip
Size: 13031 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000309/09c65842/attachment.bin>


More information about the Gcc-bugs mailing list