public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mathieu Lacage <Mathieu.Lacage@sophia.inria.fr>
To: Chris Jefferson <caj@cs.york.ac.uk>
Cc: gcc@gcc.gnu.org
Subject: Re: warn/croak on "string" "string" auto-joins
Date: Wed, 18 Aug 2004 11:17:00 -0000	[thread overview]
Message-ID: <1092826477.11457.7.camel@chronos.inria.fr> (raw)
In-Reply-To: <41232BA1.3040101@cs.york.ac.uk>

On Wed, 2004-08-18 at 12:12, Chris Jefferson wrote:
> Dave Korn wrote:
> 
>  >
>  >>>>This would have helped early and is good practice:
>  >>>>
>  >>>>char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May",
>  >>
>  >>"Jun", "Jul",
>  >>
>  >>>>"Aug" "Sep", "Oct", "Nov", "Dec"};
>  >>>>
>  >>>>--> high probability warning
>  >>>
>  >>>I'm not sure I understand, what does "high probability
>  >>
>  >>warning" mean?
>  >>
>  >>>I get no errors/warnings from the following:
>  >>>
>  >>>#include <stdio.h>
>  >>>int main( void )
>  >>>{
>  >>>  char *months[15] = {"Jan", "Feb", "Mar", "Apr", "May",
>  >>
>  >>"Jun", "Jul",
>  >>
>  >>>"Aug" "Sep", "Oct", "Nov", "Dec"};
>  >>>  printf("7: %s\n", months[8]);
>  >>>  return 0;
>  >>>}
>  >>>
>  >>>compiled with 'gcc -Wall -pedantic -ansi', using GCC 3.3.3.
>  >>
>  >>Hmm, I could have sworn that a mismatch in array dimensions
>  >>does emit a warning (too many initializers do error out "como").
>  >>Looks like this is not the case. Sorry for bothering you :-(
>  >
>  >
>  >  But it has too *few* initialisers!
>  >
> While not exactly what was asked for in the first place, it would seem 
> to me this kind of problem (giving too few initalisers to a fixed length 
> array) should definatly emit a warning.. would this be hard to do / can 
> anyone come up with a sensible reason to give too few initalisers?

While not a C standard guru, I think this is allowed and compatible with
the C99 initialization rules. Specifically, section 6.7.8, p125,
paragraphs 17, 19 and 10 which means that the end of your char *array is
initialized with null values.

regards,
Mathieu

> 
> Chris
-- 
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>

  reply	other threads:[~2004-08-18 10:55 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-17 23:26 Gabor Greif
2004-08-18  0:22 ` Adam Monsen
2004-08-18  0:49   ` Gabor Greif
2004-08-18 10:15     ` Dave Korn
2004-08-18 10:55       ` Chris Jefferson
2004-08-18 11:17         ` Mathieu Lacage [this message]
2004-08-18 11:19           ` Chris Jefferson
2004-08-18 11:36             ` Mathieu Lacage
2004-08-18 14:07               ` Robert Dewar
2004-08-18 12:55         ` Andreas Schwab
2004-08-20 11:27         ` Per Abrahamsen
  -- strict thread matches above, loose matches on Subject: below --
2004-08-17 17:37 Adam Monsen
2004-08-17 17:52 ` Zack Weinberg
2004-08-17 18:02   ` Dave Korn
2004-08-17 18:09     ` Zack Weinberg
2004-08-17 18:12       ` Dave Korn
2004-08-17 18:20         ` Andrew Pinski
2004-08-17 18:55         ` Zack Weinberg
2004-08-17 18:24       ` Adam Monsen
2004-08-17 23:25     ` Robert Dewar
2004-08-17 23:20   ` Robert Dewar
2004-08-17 23:25     ` Stan Shebs
2004-08-18  0:21       ` Robert Dewar
2004-08-18  2:43     ` Mike Stump
2004-08-18 13:16     ` Paul Koning
2004-08-18 18:08       ` Dave Korn
2004-08-19 21:20     ` Kai Henningsen
2004-08-19 21:31       ` Chris Jefferson
2004-08-20 16:25         ` Kai Henningsen
2004-08-19 21:32       ` Michael N. Moran
2004-08-19 21:53       ` Janis Johnson
2004-08-19 23:23       ` Florian Weimer
2004-08-20 16:49         ` Kai Henningsen
2004-08-17 23:02 ` Robert Dewar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1092826477.11457.7.camel@chronos.inria.fr \
    --to=mathieu.lacage@sophia.inria.fr \
    --cc=caj@cs.york.ac.uk \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).