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 17:32:03 -0400

On August 20, 2020 5:28 PM, Thomas Dickey wrote:
> On Thu, Aug 20, 2020 at 09:57:41AM -0400, Randall S. Becker wrote:
> > 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.
> 
> quoting from 6.5.7 of ANSI/ISO 9899-1990:
> 
>       If an object that has static storage duration is not initialized
>       explicitly.  it is initialized implicitly as if every member that
has
>       arithmetic type were assigned 0 and every member that has pointer
> type
>       were assigned a null pointer constant.
> 
> (TTY aka "struct termios" doesn't have pointers, otherwise some problem in
> compiling it as "const" would have surfaced).

I agree. The only concern is whether TTY or any members were a partial type
when the static declaration was made. Since it's not, I think there's
possibly a bug in the compiler. I'll take that up with the vendor. In any
event, it does not stop the compile and my tests indicate that the
initialization is 0. The c99 compiler on this platform is more strict
(sometimes too strict for its own good). So we'll carry on as is.

> > 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/../ncur
> > > > ses/ ./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
> >
> 
> --
> 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]