|
From: | Paul Eggert |
Subject: | Re: Possible UNINIT bug within man-db gl sources |
Date: | Fri, 16 Aug 2024 22:12:07 -0700 |
User-agent: | Mozilla Thunderbird |
On 2024-08-16 07:30, Bruno Haible wrote:
Copying and then discarding an uninitialized value of integer or pointer type (i.e. not a signalling NaN (*)) is not undefined behaviour.
Although that's how typical implementations behave, the C standard says that copying from a source variable has undefined behavior if the source could have been declared with 'register' (i.e., it's auto and never has its address taken). See C23 §6.3.2.1 paragraph 2. Since the code in question is copying from such a source, its behavior is technically undefined.
I recall running into a similar problem myself, when writing the mcel code, though I don't recall the details.
Proposed patch attached. I daresay there's lots of other places that would need a similar fix, assuming this one is acceptable.
0001-avltree-list-avoid-undefined-behavior.patch
Description: Text Data
[Prev in Thread] | Current Thread | [Next in Thread] |