https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84468

--- Comment #3 from Romain Geissler <romain.geissler at amadeus dot com> ---
Ok there maybe a problem with the optimizer as you describe it in bug 84470.
However why does variant 3 from comment #0 yields a warning too ?

    if (iCString)
    {
        strncpy(_cstring, iCString, 3);
        _cstring[3] = '\0';
    }
    _cstring[3] = '\0';

It is because the optimizer finds out that "_cstring[3] = '\0';" is both in the
"if branch" and also after, thus eliminates the one from the "if branch", then
the strncpy silencing warning mechanism doesn't work properly anymore ? I don't
know very well what is the internal gcc IR, but do you think it would be
possible to go beyond branches and basic block separation to find out that the
next statement in

    if (iCString)
    {
        strncpy(_cstring, iCString, 3);
    }
    _cstring[3] = '\0';

really is "_cstring[3] = '\0';" (ie crossing basic block boundaries) ?

Reply via email to