mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mitchell Blank Jr <mitch@sfgoth.com>
To: "Robert T. Johnson" <rtjohnso@eecs.berkeley.edu>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
	David Wagner <daw@eecs.berkeley.edu>
Subject: Re: &array considered harmful?
Date: Mon, 23 Feb 2004 14:49:11 -0800	[thread overview]
Message-ID: <20040223224911.GA48883@gaz.sfgoth.com> (raw)
In-Reply-To: <1077574309.16259.4.camel@dooby.cs.berkeley.edu>

Robert T. Johnson wrote:
>         memset(&A, 0, sizeof(A)); 
[...]
> This works because in C, for a local array, &A == A.  The problem is
> that this is very brittle.

I'm probably in the minority here, but I've gotten into the habit of saying
"&A[0]" since I think it's more explicit ("I want the address of the
FIRST ELEMENT of the array") and it avoids exactly the problems you mention.
It's true that it's equivelent to just saying "A" (well, almost - if "A"
is a pointer then it could be an lvalue while "&A[0]" never is) but I
like the visual cue of that "&" provides.  Matter of taste I guess -
I'm sure some people consider it ugly.

-Mitch

  reply	other threads:[~2004-02-23 22:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-23 22:11 Robert T. Johnson
2004-02-23 22:49 ` Mitchell Blank Jr [this message]
2004-02-24 12:53 ` Richard B. Johnson

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=20040223224911.GA48883@gaz.sfgoth.com \
    --to=mitch@sfgoth.com \
    --cc=daw@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rtjohnso@eecs.berkeley.edu \
    /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

all inboxes | Powered by JetHome®