Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: Tom Tromey <tromey@redhat.com>, gdb <gdb@sourceware.org>
Subject: Re: C99
Date: Wed, 17 Jul 2013 21:12:00 -0000	[thread overview]
Message-ID: <CADPb22T_1an4N4iu7M7z2Oh_NXtig5Ut73FL7k7sjZO-GK756w@mail.gmail.com> (raw)
In-Reply-To: <201307172048.r6HKmZhD018958@glazunov.sibelius.xs4all.nl>

On Wed, Jul 17, 2013 at 1:48 PM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> > However, a more important C99 "misfeature" that affects the coding
>> > standard is the possibility to declare varaibles anywhere in the code.
>> > We should not allow this, except for declaring loop variables in a
>> > for() statement.
>>
>> Can you elaborate?
>
> Code like this:
>
> int
> foobar(char *foo, int bar)
> {
>         sprintf(foo, "%d", bar)
>         int j = strlen(foo);
>         return j;
> }
>
> is bad if you're trained to look for variable declerations at the
> start of a block.  C90 doesn't allow this; C99 changed that.  Most
> hardcore C programmers consider this a bad decision by the standard
> committe.  Most people do accept the following though:
>
> int
> foobar(int bar)
> {
>     int sum = 0;
>
>     for (int i = 0; i < bar; i++)
>         sum += i;
>
>
>     return sum;
> }

Yeah, except I'm not seeing why it's a problem.  Why is it a bad
decision?  What class of bugs does it cause?
I can see that it makes it easier to find all the locals, but I'm more
for declaring/initializing them close to their use.


  reply	other threads:[~2013-07-17 21:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-16 20:51 C99 Tom Tromey
2013-07-16 21:23 ` C99 Mark Kettenis
2013-07-16 21:40   ` C99 Doug Evans
2013-07-17 20:48     ` C99 Mark Kettenis
2013-07-17 21:12       ` Doug Evans [this message]
2013-07-17  8:11   ` C99? No, portability John Gilmore
2013-07-17 22:38     ` Doug Evans
2013-07-18 15:27       ` John Kearney
2013-07-19 17:39         ` Doug Evans
2013-07-18  6:54   ` C99 Yao Qi
2013-07-17  3:49 ` C99 Eli Zaretskii
2013-07-17 17:54   ` C99 Doug Evans
2013-07-18  2:47     ` C99 Yao Qi
2013-07-18  6:46       ` C99 Doug Evans

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=CADPb22T_1an4N4iu7M7z2Oh_NXtig5Ut73FL7k7sjZO-GK756w@mail.gmail.com \
    --to=dje@google.com \
    --cc=gdb@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    --cc=tromey@redhat.com \
    /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