[Top][All Lists]

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

Use of -fwrapv compiler flag?

From: Jeffrey Walton
Subject: Use of -fwrapv compiler flag?
Date: Mon, 23 Oct 2017 16:20:58 -0400

This caught my eye while building with V=1:

/bin/sh ../libtool  --tag=CC   --mode=link gcc -std=gnu11 -Wall
-Wmissing-prototypes -Wdeclaration-after-statement -Wpointer-arith
-Wswitch-enum -fno-strict-aliasing -fwrapv -m64 -march=native
-export-dynamic -no-undefined -module -m64 -Wl,-rpath,/usr/local/lib64
-L/usr/local/lib64 -Wl,--enable-new-dtags -o -rpath
/usr/local/lib64/guile/2.2/extensions readline.lo -L/usr/local/lib64
-lreadline -R/usr/local/lib64 -lncurses  ../libguile/
../lib/ -lcrypt -ldl -lpthread -lm

-fwrapv is used by illegal programs to try to get them to run. Also
see Ian Lance Taylor's blog at
It would probably be a good idea to remove the undefined behavior
rather than compiling with -fwrapv.

If its not clear where the undefined behavior is, then
-fsanitize=undefined can usually pinpoint them (or most of them).
Autotool projects can be kind of tricky.
CFLAGS=CXXFLAGS="-fsanitize=undefined" and LDFLAGS="-lubsan" usually
works (it looks like it works Guile). Then, run the self tests and
generate the findings.

-fno-strict-aliasing is another flag that's usually indicates code
with room for improvement.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]