Pelles C > General discussions

Pelles V11 Warnings

<< < (2/2)

Pelle:
A part of the optimizer will attempt to remove "dead stores" to "memory", mainly to aggregates (array/struct) with it's address taken.
If the single use of such a local aggregate is to be cleared by memset(), this is pointless. The memset() and variable can be removed.
This is similar to initializing an array without using it, like:

--- Code: ---char buf[80] = {0};
--- End code ---
The "dead store" removal will be the same, but you will get different warnings because the compiler inserted the memset() in the latter case.
If you have multiple uses of a local aggregate it's assumed you are doing something useful with it. The analyze (before removal) of multiple uses is a bit harder, and repeatedly clearing an aggregate without actually using it seems too stupid to waste much time on...

John Z:
I understand.  I was evidentially doing added unneeded work in the compiler optimization analysis of the code.

To clarify further - in the 'real' code all of the variables are actually used, all of that code was just stripped out to just get the smallest code to investigate the warning.

The double memset was never done in the real code, just a curiosity (what would happen if) test case.

I appreciate everyone's inputs and comments!  Always more to learn, and depth to gain.

John Z

Navigation

[0] Message Index

[*] Previous page

Go to full version