[Bug c/85365] -Wrestrict false positives with -fsanitize=undefined
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Apr 13 02:01:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85365
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |msebor at gcc dot gnu.org
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
The sanitizers insert a lot of instrumentation, and some of it interferes with
GCC warnings. The usual recommendation is to use either sanitization or
middle-end warnings but not both. (This is obviously suboptimal and it would
be ideal to have both, but it's not always possible.)
Much of the instrumentation the sanitizers insert is, of course, necessary to
detect bugs and runtime, but some is not (e.g., some of those in bug 79265) and
could be removed to avoid some of the false positives with no loss of efficacy
(and make the code run faster).
The output of the sanitizer for the first function shows a couple of these
unnecessary tests (I don't know if avoiding the would prevent the warning; it's
issued while running the VRP pass):
t1 (char * g)
{
int c.1_1;
char * _2;
char * _3;
long unsigned int _4;
int _5;
char[<unknown>] * iftmp.0_6;
char[<unknown>] * iftmp.0_8;
char[<unknown>] * iftmp.0_9;
<bb 2> :
c.1_1 = c;
if (c.1_1 != 0)
goto <bb 3>; [INV]
else
goto <bb 4>; [INV]
<bb 3> :
iftmp.0_8 = &b;
goto <bb 5>; [INV]
<bb 4> :
iftmp.0_9 = &a;
<bb 5> :
# iftmp.0_6 = PHI <iftmp.0_8(3), iftmp.0_9(4)>
UBSAN_PTR (g_10(D), 4);
_2 = g_10(D) + 4;
if (_2 == 0B)
goto <bb 7>; [0.05%]
else
goto <bb 6>; [99.95%]
<bb 7> :
__builtin___ubsan_handle_nonnull_arg (&*.Lubsan_data0);
<bb 6> :
if (iftmp.0_6 == 0B) <<< unnecessary (neither &a nor &b can be null)
goto <bb 9>; [0.05%]
else
goto <bb 8>; [99.95%]
<bb 9> :
__builtin___ubsan_handle_nonnull_arg (&*.Lubsan_data1);
<bb 8> :
strcpy (_2, iftmp.0_6);
UBSAN_PTR (g_10(D), 4);
_3 = g_10(D) + 4;
if (_3 == 0B) <<< redundant (already checked in bb 5
goto <bb 11>; [0.05%]
else
goto <bb 10>; [99.95%]
<bb 11> :
__builtin___ubsan_handle_nonnull_arg (&*.Lubsan_data2);
<bb 10> :
_4 = strlen (_3);
_5 = (int) _4;
e = _5;
return;
}
More information about the Gcc-bugs
mailing list