Sujet : Re: int a = a (Was: Bart's Language)
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 18. Mar 2025, 20:11:21
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250318120705.662@kylheku.com>
References : 1 2 3 4 5 6
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-03-18, Janis Papanagnou <janis_papanagnou+
ng@hotmail.com> wrote:
On 18.03.2025 19:04, Kenny McCormack wrote:
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".
>
Wow! - It would never have occurred to me that "int a = a;" being
considered an idiom, let alone a "common idiom".
Suppose the program is well-defined with "int a;"; just the compiler
is not smart enough to analyze it, and so it warns about a potential
use of an uninitialized variable.
When you add this "idiom", you may be introducing undefined behavior
into the declaration.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca