This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Please review the fortran part of change for PR79538 missing -Wformat-overflow with %s and non-member array arguments


On Fri, Dec 8, 2017 at 12:29 AM, Qing Zhao <qing.zhao@oracle.com> wrote:
> Hi, fortran team,
>
> Please review the fortran part of change for PR79538.
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79538 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79538> <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79538 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79538>>
> missing -Wformat-overflow with %s and non-member array arguments
>
> -Wformat-overflow uses the routine "get_range_strlen" to decide the
> maximum string length, however, currently "get_range_strlen" misses
> the handling of non-member arrays.
>
> Adding the handling of non-member array resolves the issue.
> Adding test case pr79538.c into gcc.dg.
>
> During gcc bootstrap, 2 source files (c-family/c-cppbuiltin.c,
> fortran/class.c) were detected new warnings by -Wformat-overflow
> due to the new handling of non-member array in "get_range_strlen".
> in order to avoid these new warnings and continue with bootstrap,
> updating these 2 files to avoid the warnings.
>
> in c-family/c-cppbuiltin.c, the warning is following:
>
> ../../latest_gcc_2/gcc/c-family/c-cppbuiltin.c:1627:15: note:
> ‘sprintf’ output 2 or more bytes (assuming 257) into a destination
> of size 256
>      sprintf (buf1, "%s=%s", macro, buf2);
>      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> in the above, buf1 and buf2 are declared as:
> char buf1[256], buf2[256];
>
> i.e, buf1 and buf2 have same size. adjusting the size of buf1 and
> buf2 resolves the warning.
>
> fortran/class.c has the similar issue as above. Instead of adjusting
> size of the buffers, replacing sprintf with xasprintf.
>
> bootstraped and tested on both X86 and aarch64. no regression.
>
> Okay for trunk?

Fortran parts are Ok, thanks.

-- 
Janne Blomqvist


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]