extern const initialized warns in C

Vincent Lefevre vincent+gcc@vinc17.org
Mon Jan 22 16:22:00 GMT 2018


On 2018-01-22 10:53:55 +0100, David Brown wrote:
> On 22/01/2018 10:31, Jay K wrote:
> > 
> > By this argument there is a missing warning for the equivalent:
> > 
> >    const int foo = 123;
> > 
> > with no previous extern declaration.
> 
> I would like to see such a warning.  There is "-Wmissing-declarations",
> but that applies only to functions and not to objects.

I would like such a warning too. FYI, a few days I fixed in bug in
MPFR, which was defining an exported symbol outside of its prefix
under some conditions and could yield problems with multiple defined
symbols once linked with GMP. This remained undetected since this
was internal to some file and was related to code obtained from GMP
(with the preprocessor involved too). Such a warning would have
detected a potential issue via automated tests since the symbol
isn't pre-declared in .h files.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



More information about the Gcc mailing list