Re: current gcc 12.4.0 bug

[email protected] Sat, 28 Sep 2024 07:57:44 +0200
Newsgroups gmane.os.netbsd.devel.toolchain
Message-ID <[email protected]>
On Sat, Sep 28, 2024 at 01:24:39PM +1000, matthew green wrote:
> [email protected] writes:
> > I'm running current and stumbled on that:
> >
> > exec.c: In function 'shellexec':
> > exec.c:145:46: error: '%s' directive argument is null
> > [-Werror=format-overflow=]
> >   145 |         (void)fprintf(stderr, "do_qfilename (%s): %d\n",
> >       |                                              ^~
> > cc1: all warnings being treated as errors
> >
> > While the argument is not NULL.
> >
> > It's a bug in gcc see:
> >
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90036
> >
> > With this around, how can we be sure that the generated code is
> > correct?
> 
> looks like it's been a bug since GCC 8, and that the problem is
> a *missing* optimisation, so, i'd just go with ignoring it either
> with a -Wno- or going with "assert(foo)" before the fprintf(),
> as recommended in the above PR.
> 
> i can't get any of the examples in the PR to fail for me though,
> with GCC 10 or GCC 12 (both pkgsrc or gcc native.)
> 

I did get around with inserting an assert() as suggested in the bug report
above.

It's the analysis of the code that is incorrect so perhaps not the
produced code by itself. Nonetheless, it's uncomfortable (when one
doesn't know if he has to look for bugs in his code or in gcc)...
-- 
        Thierry Laronde <tlaronde +AT+ kergis +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C