On 2018-10-16 13:21, Stanislaw Gruszka wrote:
> On Tue, Oct 16, 2018 at 01:19:52PM +0200, Felix Fietkau wrote:
>> > I have no idea how this could be related. But I think I found
>> > somewhat reasonable explenation where the problem is.
>> > I think below code :
>> > 
>> >    if (a || b || c) {
>> >            CODE1();
>> >    } else if (c) {
>> >            CODE2();
>> >    }
>> > 
>> > can not be deterministic and can be compiled differently depending
>> > on compiler version and used options. Sometimes it could result
>> > in this 
>> > 
>> >    if (a || b || c) {
>> >            CODE1();
>> >    }
>> > 
>> > and sometimes in this:
>> > 
>> >    if (a || b) {
>> >            CODE1();
>> >    } else if (c) {
>> >            CODE2();
>> >    }
>> > 
>> > So that would explain the problems you see. And indeed patch
>> > could cause regression on systems where second variant of
>> > initalizing RT6352 registers was used.
>> I don't see how that can be non-deterministic at all. The 'else if' part
>> can only be hit if the first if did not match.
> 
> I meant non-deterministic during compilation process, when compiler
> do or do not some optimizations or if compiler version differs.
In my opinion, this is not C undefined behavior territory. The compiler
is not allowed to change the behavior here based on optimization settings.

- Felix

Reply via email to