On Tue, 12 Dec 2023, Jonathan Wakely via Gcc wrote:

> On Mon, 11 Dec 2023, 17:08 Jingwen Wu via Gcc, <gcc@gcc.gnu.org> wrote:
> 
> > Hello, I'm sorry to bother you. And I have some gcc compiler optimization
> > questions to ask you.
> > First of all, I used csmith tools to generate c files randomly. Meanwhile,
> > the final running result was the checksum for global variables in a c file.
> > For the two c files in the attachment, I performed the equivalent
> > transformation of loop from *initial.**c* to *transformed.c*. And the two
> > files produced different results (i.e. different checksum values) when
> > using *-O2* optimization level, while the results of both were the same
> > when using other levels of optimization such as *-O0*, *-O1*, *-O3*, *-Os*,
> > *-Ofast*.
> > Please help me to explain why this is, thank you.
> >
> 
> Sometimes csmith can generate invalid code that gets miscompiled. It looks
> like you're compiling with no warnings, which is a terrible idea:
> 
> 
> > command line: *gcc file.c -O2 -lm -I $CSMITH_HOME/include && ./a.out*
> >
> 
> You should **at least** enable warnings and make sure gcc isn't pointing
> out any problems in the code.
> 
> You should also try the options suggested at http://gcc.gnu.org/bugs/ which
> help identify invalid code.

Let me also link the "Testing Compilers Using Csmith" page, which is
currently available via the Wayback Machine, but not its original URL:

https://web.archive.org/web/20230316072811/http://embed.cs.utah.edu/csmith/using.html

It was written by the developers of Csmith.

Alexander

Reply via email to