[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[csmith-bugs] unsigned int literals and --ccomp



Dear Csmith developers,

[ This is more of a question than a bug report.  Apologies about
that. ]

I noticed that csmith --ccomp does not (purposefully) suffix unsigned
int literals with "U".  This causes GCC to warn, probably rightly so:

xleroy@jollyjumper:~/tmp/csmith-2.0.0$ src/csmith --seed 123 --ccomp >
/tmp/testfile.c
xleroy@jollyjumper:~/tmp/csmith-2.0.0$ gcc -m32 -I runtime -c /tmp/testfile.c
/tmp/testfile.c: In function func_19:
/tmp/testfile.c:290: warning: this decimal constant is unsigned only in ISO C90

Passing -std=c89 to GCC doesn't silence that warning (hmmph), but
warns about something else in your include files that you may want to
know about:

xleroy@jollyjumper:~/tmp/csmith-2.0.0$ gcc -std=c89 -m32 -I runtime -c
/tmp/testfile.c
In file included from runtime/csmith.h:45,
                 from /tmp/testfile.c:10:
runtime/random_inc.h:133:8: warning: extra tokens at end of #endif directive
/tmp/testfile.c: In function func_19:
/tmp/testfile.c:290: warning: this decimal constant is unsigned only in ISO C90

But I'm dying to know: why is it that with --ccomp Csmith omits the U
suffix?  Did you find a problem in CompCert that this would trigger?
Please tell me!

I browsed your sources to try to answer my question, and instead came
up with one more question:

In src/Constant.cpp, line 276:

		    if (CGOptions::ccomp())
		    	v = oss.str();
		    else
			v = oss.str() + (type->is_signed() ? "L" : "U");

"U" means "unsigned", but "L" doesn't mean "signed", it means "long".
I would have expected either

			v = oss.str() + (type->is_signed() ? "L" : "UL");

if you really want to force all constants to be long (really?), or

			v = oss.str() + (type->is_signed() ? "" : "U");

if you don't.

Sorry for nosing around in your source code.  But I'd really love to
know why ccomp might have a problem with literals such as
"4294967295U" !

- Xavier