Sujet : Re: int a = a (Was: Bart's Language)
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.cDate : 19. Mar 2025, 07:52:20
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86zfhhpl5n.fsf@linuxsc.com>
References : 1 2 3 4 5
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
gazelle@shell.xmission.com (Kenny McCormack) writes:
In article <vrc75b$2r4lt$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
...
>
gcc won't warn until you say '-Wextra', and then only for:
>
int a = a + 1;
>
People would not normally write "int a = a;". It is used as a
common idiom meaning "I know it is not clear to the compiler that
the variable is always initialised before use, but /I/ know it is -
so disable the use-without-initialisation warnings for this
variable". So it makes perfect sense for the compiler not to warn
about it!
An addle-brained view. Anyone who thinks that should be forcibly
removed from any activity involving software development.
Wouldn't it just be easier and clearer to write: int a = 0;
and be done with it?
There are two problems: one, the semantics are different; and two,
the impression given of the author's intent is different. It's kind
of like saying "isn't it just easier and clearer to write 'red'
rather than 'yellow'?" Writing 'int a = 0;' might be better or it
might be worse, depending on one's point of view, but it shouldn't
be considered either more clear or less clear, because it isn't
saying the same thing.