On 03/05/2019 12:39, Bertrand Dekoninck wrote:
SEL aSelector = @selector(themeControlState);
GSThemeControlState buttonState = (GSThemeControlState)[self
performSelector:aSelector withObject:nil];
This is not only wrong, it is undefined behaviour. You are calling a
function that returns an int (well, an enum, but in C that practically
means an int) with a signature that returns a pointer. You are then
converting the result to an int. If you are lucky, the calling
convention will return an int and a pointer in the same place (register
or stack), but this is not guaranteed by the language and, if the
compiler spots that this is what you're doing then it is free to do
whatever it likes with your code.
Concretely, it is almost certainly broken on 64-bit big-endian systems,
where the int will be returned in the first 4 bytes of a register /
stack location and this will be taking the second 4 bytes. You may be
lucky and find that the in-register return works, but it's fragile.
TL;DR: Please don't do this.
David
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep