[fpc-devel] "unused variable" depends on optimization?
Florian Klämpfl
florian at freepascal.org
Sun Feb 23 15:30:58 CET 2025
> Am 23.02.2025 um 14:26 schrieb Martin Frb via fpc-devel <fpc-devel at lists.freepascal.org>:
>
> On 23/02/2025 14:16, Jonas Maebe via fpc-devel wrote:
>> On 23/02/2025 14:14, Martin Frb via fpc-devel wrote:
>>> Is it correct (i.e. by design) that the compiler emits some "may not be initialized" warnings, only on certain optimization levels?
>>
>> Yes. Those warnings depends on data flow analysis, which is only enabled by defaullt at -O3 and higher. You can also enabled it separately with -Oodfa.
>
> Ok, so without dfa it does not omit the warning, probably because it has see that there was a conditional initialization? (i.e. might be ok, at least sometimes, even if certainly not always)
>
> Meaning -O1 is lenient in its checks, because they are not as evolved.
Yes, with -O1 the compiler does not see that the variable is initialized only conditionally. With -Oodfa/-O3 it takes care of this but actually it should also know about the condition being the same, something it cannot do at any optimization level.
More information about the fpc-devel
mailing list