Niels Grewe wrote:

> On 29.05.2013 10:06CEST Philippe Roussel <[email protected]> wrote:
> 
>> DKMethod.m:618:28: error: array index of '2' indexes past the end of an 
>> array (that contains 2 elements) [-Werror,-Warray-bounds]
>>   NSAssert2((0 == strcmp(@encode(id), [sig methodReturnType])),
>>   ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> /usr/include/i386-linux-gnu/bits/string2.h:812:21: note: expanded from:
>>           : __strcmp_cg (s1, s2, __s1_len))                                 \
>>                          ^
>> /usr/include/i386-linux-gnu/bits/string2.h:882:25: note: expanded from:
>>                                        (__const char *) (s1))[2] - __s2[2]);\
>>                                                          ^
>> /opt/GNUstep-trunk/include/Foundation/NSException.h:454:20: note: expanded 
>> from:
>>   _NSAssertArgs((condition), (desc), (arg1), (arg2))
>>                  ^
>> /opt/GNUstep-trunk/include/Foundation/NSException.h:407:8: note: expanded 
>> from:
>>       if (!(condition)) {                                     \
>>             ^~~~~~~~~
>> DKMethod.m:618:28: error: array index of '3' indexes past the end of an 
>> array (that contains 2 elements) [-Werror,-Warray-bounds]
>>   NSAssert2((0 == strcmp(@encode(id), [sig methodReturnType])),
>>   ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> /usr/include/i386-linux-gnu/bits/string2.h:812:21: note: expanded from:
>>           : __strcmp_cg (s1, s2, __s1_len))                                 \
>>                          ^
>> /usr/include/i386-linux-gnu/bits/string2.h:885:27: note: expanded from:
>>                                         (__const char *)  (s1))[3]          \
>>                                                            ^
>> /opt/GNUstep-trunk/include/Foundation/NSException.h:454:20: note: expanded 
>> from:
>>   _NSAssertArgs((condition), (desc), (arg1), (arg2))
>>                  ^
>> /opt/GNUstep-trunk/include/Foundation/NSException.h:407:8: note: expanded 
>> from:
>>       if (!(condition)) {                                     \
>>             ^~~~~~~~~
>> 5 errors generated.
> 
> Now that looks fundamentally weird. I've got no clue what's going on there. 
> It works with clang trunk. Maybe a preprocessor bug that's been fixed? Could 
> you check whether replacing NSAssert2 with a plain NSAssert fixes it? 

It's apparently an issue of the weird definition that strcmp expands into (have 
a look at /usr/include/i386-linux-gnu/bits/string2.h and have fun with it). It 
uses the preprocessor to expand comparisons involving short constant strings 
into inline code. I guess someone must have spent days running microbenchmarks 
to come up with this code.

Wolfgang


_______________________________________________
Gnustep-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to