|
|
Richard wrote:
> Ioannis Vranos <ivranos@xxxxxxxxxxxxxxxxxxxxxxxxx> writes:
>
>> Willem wrote:
>>> Ioannis wrote:
>>> ) Willem wrote:
>>> )> And what about the not 'in general' cases where there are valid reasons
>>> )> for variables to be declared register in large scopes ?
>>> )>
>>> )> Those are the interesting cases that are counterexamples to your claim
>>> )> that a compiler is defective if it generates less-efficient code when
>>> )> 'register' is used. Therefore those are the cases under discussion.
>>> )>
>>> )> Or are you claiming that *all* those cases are 'improper use' ?
>>> )
>>> ) I think "register" should be used in as small scopes as possible, the
>>> ) same way that "inline" should be used with as small functions as possible.
>>>
>>> And I think that cases exist where the smallest scope possible is such that
>>> it will touch multiple code paths, making one more efficient at the cost of
>>> others. It is the programmers discretion to make this choice.
>>> These cases are counterexamples to your claim.
>>
>> Can you provide some code example where this happens, since I am not a
>> compiler writer?
>
> I think the onus of proof is on you since you are the one making claims
> against the situation backed by fairly reasonable assertions and common
> sense.
I am not sure about the "fairly reasonable assertions and common sense"
you are mentioning. I said "register" should be used in as small scopes
as possible and I provided a code example where a "register" variable is
used in a for-loop scope only.
A "register" variable is usually not needed where it is not accessed
intensively.
Willem mentioned some counter-examples for small scopes. I would like to
see some actual code demonstrating one or more of those.
|
|