2013/3/15 Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>: > Am 15/03/2013 15:41, schrieb Pawel Dziepak: >> >> 2013/3/14 Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>: >> >>> Isn't that just a porting issue? >>> Somewhere GCC stores that information, and it's usually right. Just not >>> on >>> Haiku. IMO one should "simply" update GCC to know that strdup(), free(), >>> etc. accept NULL pointers. >> >> The problem is that GCC applies the same attributes to both built-in >> functions and their user defined version even if eventually the >> built-in version is never used. Changing the attributes of GCC >> built-in functions is trivial this [1] patch for GCC would do this for >> strdup() and solve this particular problem. However, if anyone tried >> to compile anything that uses built-in strdup() GCC would have wrong >> information about it (and that may result in another problem). > > > I think a complete patch would indeed also patch the built-ins to follow the > same logic. > > Do the built-ins only contain the clib built-ins, or would other built-ins > also be affected (like byte swapping routines, etc.)? If it would only > affect clib built-ins, then I think disabling them by default would > certainly be a valid option. I've checked and unless I am missing something strdup() is the only function that our implementation allows NULL pointer in argument while the standard does not. (You've mentioned free() earlier but it accepts NULL pointers in standard version either.) In that case I think the best solution is to disable that particular built-in function (-fno-builtin-strdup) and add attributes (pure, nothrow, leaf) to its declaration. For bcopy(), bzero() and bcmp() it is the other way round. GCC built-in versions accept NULL pointers while our implementation does not. If we really do not want them to accept NULL pointers it may be a good idea to add attribute nonnull to their declarations. Paweł