[Top][All Lists]

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

Re: [lwip-users] lwip has errors with linker optimization enabled

From: Johan Borkhuis
Subject: Re: [lwip-users] lwip has errors with linker optimization enabled
Date: Fri, 18 Jan 2019 20:10:23 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

Op 18-1-2019 om 18:00 schreef Sergey A. Borshch:
On 18.01.2019 8:59, star keeper wrote:
But in my opinion this is also a bad coding habit and can easily be fixed by giving the constants different values.
No, It's not a bad practice, it's an IAR violation to C language standard, see 6.5.9 Equality operators:

Two pointers compare equal if and only if both are null pointers, *both are pointers to the same object* (including a pointer to an object and a subobject at its beginning) or function, both are pointers to one past the last element of the same array object, or one is a pointer to one past the end of one array object and the other is a pointer to the start of a different array object that happens to immediately follow the first array object in the address space.

It is indeed a strange implementation, but when looking at the IAR documentation is states:

Use this option to keep only one copy of equivalent read-only sections. Note that this can cause different functions or constants to have the same address, so an application that depends on the addresses being different will not work correctly with this option enabled.

So it is a special optimization of the IAR linker, one that I would try to stay away from, as it might be causing more problems that you did not (yet) detect, especially if you are using more libraries.


reply via email to

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