From: Andrew Cagney <ac131313@cygnus.com>
To: Daniel Jacobowitz <drow@mvista.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [patch/ob]
Date: Tue, 11 Dec 2001 18:40:00 -0000 [thread overview]
Message-ID: <3C16C391.9020506@cygnus.com> (raw)
In-Reply-To: <20011211144152.A22746@nevyn.them.org>
> On Tue, Dec 11, 2001 at 10:18:05AM -0800, Andrew Cagney wrote:
>
>> Just FYI,
>>
>> I've checked the attached in as, er, obvious. It fixes a
>> -Wuninitialized warning.
>
>
> I agree with the "er, obvious".
>
> Would there be anything wrong with:
>
>
>> *************** value_fn_field (value_ptr *arg1p, struct
>> *** 971,983 ****
>> struct minimal_symbol *msym;
>
>
> adding = NULL to the line above?
6 of one, half a dozen of the other.
My personal preference is to do an initialization as:
if (expr)
foo = val1;
bar = valb;
baz = valz;
else if (expr2)
foo = val2;
bar = valxx;
bas = val3;
else
foo = defaultval;
bar = devbar;
baz = baxdev;
rather than:
bar = devbar;
baz = baxdev;
...
...
...
...
...
...
if (expr)
foo = val1;
bar = valb;
else if (expr2)
foo = val2;
baz = val3;
This is because I consider the former to have clear pre/post assertions
and exploits the compiler's -Wuninitialized facility - you know all
branches have initialized foo, bar and baz (I'm not sure about the
latter example mind :-). This becomes especially useful when handling
initialization in in very long switches and if/elif chains.
> + gdb_assert (sym == NULL);
>
>
> This assert in particular bugs me. Adding asserts that the compiler
> can obviously eliminate, since sym isn't volatile...
Here, sorry, I'm lost. Assertions are added to code for many reasons -
one being that it helps ``prove'' correctness, another is that it can
clarify the intention and assumptions of the developer. I don't think
compiler has much to do with this.
Keep in mind that we use GCC's -Werror messages as a tool. Not as an
end in themselves.
enjoy,
Andrew
prev parent reply other threads:[~2001-12-12 2:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-11 10:18 [patch/ob] Andrew Cagney
2001-12-11 11:43 ` [patch/ob] Daniel Jacobowitz
2001-12-11 18:40 ` Andrew Cagney [this message]
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=3C16C391.9020506@cygnus.com \
--to=ac131313@cygnus.com \
--cc=drow@mvista.com \
--cc=gdb-patches@sources.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