Sujet : Re: int a = a (Was: Bart's Language)
De : Ros (at) *nospam* invalid.invalid (Rosario19)
Groupes : comp.lang.cDate : 19. Mar 2025, 13:23:57
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <pjdltjh6tsgu9nt3oov0uhgqtla7tm69ek@4ax.com>
References : 1 2 3 4 5 6
User-Agent : Forte Free Agent 1.93/32.576 English (American)
On Tue, 18 Mar 2025 23:52:20 -0700, Tim Rentsch wrote:
(Kenny McCormack) writes:
>
David Brown 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.
int a=a;
for me initialize "a" variable with a value the compiler found right
as in
int a;
only possibly silence compiler warning for variable not initializated