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]

sprintf core dumps compiling with gcc 2.95 for ultrasparc


//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


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