[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] master 6cd5678: Clarify compiler-pacifier in frame.c

From: Paul Eggert
Subject: Re: [Emacs-diffs] master 6cd5678: Clarify compiler-pacifier in frame.c
Date: Tue, 27 Aug 2019 05:05:33 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

Eli Zaretskii wrote:

Do you have a guess why GCC might get lost in that code?

Sure, lots of guesses. GCC may have a limit on how many variables it's willing to analyze before it gives up. Or maybe it has a limit on the complexity of the mask being used. Or maybe it's just using range and oddity analyses and that works only up to two-bit masks. (I should say that GCC is "lost" only in the sense that it's issuing bogus warnings; it's still generating correct code.)

To illustrate, please see the attached file maybe-uninitialized.c. When I compile it with 'gcc -O2 -Wmaybe-uninitialized -S maybe-uninitialized.c' on Fedora 30 x86-64, GCC warns that w, x, and y might be used uninitialized in bar4. It doesn't warn about h in bar4 even though h is initialized using the same strategy as the others. GCC also doesn't warn about bar2's locals even though bar 2 uses the same strategy as bar4. All the warnings GCC issues are false alarms, and these false alarms come from bar4 (with 4 variables) rather than from bar2 (with only 2).

And how should GCC know that?

GCC could use the same sort of reasoning I used.

Which reasoning is that?  You haven't presented your reasoning for
XParseGeometry, AFAICT.  You presented reasoning for some other code,
which you consider similar.

I presented the reasoning GCC's bogus warning about XParseGeometry's caller in this earlier email:


If that presentation wasn't clear enough I can go into it in more detail; just let me know which parts weren't clear. Perhaps maybe-uninitialized.c will help explain things too.

UNINIT is for you to be able to use your tools of choice, and
perhaps also to cater to your personal stylistic preferences.

It's not just me using those tools. And UNINIT is not my stylistic preference: I don't like using UNINIT and when variables need not be initialized I'd rather just not initialize them (this is the longstanding tradition in GNU and UNIX code). The only reason for UNINIT is that it's more useful for preventing and catching bugs than its alternatives are.

Attachment: maybe-uninitialized.c
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]