------- Comment #4 from jakub at gcc dot gnu dot org  2009-10-19 12:06 -------
For a suspected wrong-code bug, the standard way to create a testcase is to
first find out if there are gcc options with which you get the expected result
(such as it works when compiled with -O0, doesn't when compiled with -O2), or,
if even at -O0 new gcc misbehaves some other compiler version.
Then either guess or do a binary search between objects compiled with a known
good and known bad options to narrow it down to a particular source file.
Then try -fno-inline on that file to see if it is still bad, if it is, it will
be far easier, as no inlining is performed and thus fn boundaries are clearer.
In any case either guess the miscompiled function or play with attribute
optimize (known to have issues though) or splitting source file into several
smaller ones to do a binary search to a particular function.
Last, find out what arguments it has been called with and try to emulate that
inside of a main, just preparing the right arguments (and what they point to
etc.), then calling only the problematic function.  And, stub all (noninlined)
functions the problematic function calls, with something that gives back the
right result, use noinline attribute on it and possibly asm volatile
("":::"memory"); to prevent it being optimized.  Remove any unnecessary stuff,
provide it as preprocessed source, which can be run and show clearly a bad vs.
good behavior (say exit 0 in the right case, abort otherwise).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41750

Reply via email to