public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joe Buck <Joe.Buck@synopsys.COM>
To: Sylvester Diehl <diehl@dachau.marco.de>
Cc: gcc@gcc.gnu.org
Subject: Re: attribute initialized
Date: Mon, 11 Jul 2005 19:06:00 -0000	[thread overview]
Message-ID: <20050711190637.GB30995@synopsys.com> (raw)
In-Reply-To: <m1Ds2ga-007uQcC@hera.dachau.marco.de>

On Mon, Jul 11, 2005 at 08:07:20PM +0200, Sylvester Diehl wrote:
> why doesn't gcc (-Wall -Wuninitalized -O) detect 
> an uninialized variable passed by reference
> decleared as <type> const *<name> ?

There are no uninitialized variables in your program.  For the
kind of access checking you seem to be asking for, you'll need
something like valgrind or mudflap.

> int foo(int const *p)
> {
> 	static int sum = 0;
> 
> 	sum += *p;
> 	return sum;
> }

it happens that the memory that p points to is unitialized, but
that is not what -Wuninitialized does.  Similarly, in

> int main(int argc, char **argv)
> {
> 	int k;
> 
> 	return printf("%d\n", foo(&k));
> }

there are no uninitialized variables, as the address of k is
perfectly well defined.

> p.s. i know i could pass the variable by value
>      to get a warning of an uninitalized variable.

Yes, because then there will *be* an unitialized variable.

  reply	other threads:[~2005-07-11 19:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-11 18:07 Sylvester Diehl
2005-07-11 19:06 ` Joe Buck [this message]
2005-07-12  9:34   ` Dave Korn
2005-07-12  9:56     ` Falk Hueffner
2005-07-12  9:56       ` Dave Korn
2005-07-13 14:09     ` Sylvester Diehl

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=20050711190637.GB30995@synopsys.com \
    --to=joe.buck@synopsys.com \
    --cc=diehl@dachau.marco.de \
    --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).