bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Compile Error in c99


From: Randall S. Becker
Subject: RE: Compile Error in c99
Date: Thu, 20 Aug 2020 09:57:41 -0400

Looking at the current C standard, it appears that the compiler is actually
wrong about the warning, unless as below. If a scalar, it is supposed to
initialize to 0 when unspecified. I did run a test on the platform for this
specific situation and the value of scalars are correctly initialized to 0.
This was tested in isolation, but succeeded and did not generate the
warning, making me wonder whether there is something about the TTY type that
is confusing the compiler at that point. Note that the standard does not
provide initialization if TTY is a partial type when the static is
encountered.

I'm a bit perplexed about the compiler's conduct here.

Regards,
Randall

--
Randall S. Becker
ITUGLIB Process Designer, Repository Manager, Occasional Porting Dude
+1.416.984.9826
 NonStop developer since approximately 211288444200000000
 UNIX developer since approximately 421664400
-- In my real life, I talk too much.


> -----Original Message-----
> From: Thomas Dickey <dickey@his.com>
> Sent: August 20, 2020 4:04 AM
> To: Randall S. Becker <rsbecker@nexbridge.com>
> Cc: 'Ncurses Mailing List' <bug-ncurses@gnu.org>
> Subject: Re: Compile Error in c99
> 
> On Wed, Aug 19, 2020 at 07:23:29PM -0400, Randall S. Becker wrote:
> > The c99 compiler used on NonStop caught this one. I think it's legit:
> >
> >      static const TTY null_TTY;       /* all zeros iff uninitialized */
> >
> >                                ^
> >
> > "/home/jenkins/.jenkins/workspace/Ncurses_Pipeline/ncurses/../ncurses/
> > ./base /lib_set_term.c", line 309: warning(338):
> >
> >           const variable "null_TTY" requires an initializer
> >
> > A const scalar should be initialized. Do not depend on the compiler to
> 
> longstanding practice says that static variables are guaranteed to be
zeroed
> (this compiler appears to ignore the "static").  I guess that's something
to
> verify vs the C and POSIX standards...
> 
> > generate initialization code. This may come from whatever is on the
> > stack instead of memory, which is assumed for globals, but not for
> > stack variables.
> 
> static variables aren't on the stack...
> 
> --
> Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
> ftp://ftp.invisible-island.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]