https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98055
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |WONTFIX CC| |msebor at gcc dot gnu.org --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- The -Wunused-result warning applies to calls to the GCC alloca built-in function that allocate space on the stack. To use replacement implementations of the function the built-in must be disabled by -fno-builtin-alloca. That also suppresses the warning. This behavior applies in general to other built-in functions as well, including malloc (and including calls to malloc(0) which need not allocate any memory and returns null on some implementations). Diagnosing unportable code, either to other implementations or even to different configurations of GCC, could be a useful feature, but it's not the purpose of existing warnings. Their goal is to detect potential problems given the current target, under the options in effect. As an example, take -Wpointer-to-int-cast which only diagnoses slicing conversion under the selected data model (e.g., pointer to int in LP64 but not in ILP32). Broadening the scope of existing warnings to portability would need to be done under the control of some sort of a -Wportability option that, to be useful and not overly noisy, would also need to specify the target(s) to which the code is intended to be portable. Otherwise, to continue with the example of -Wpointer-to-int-cast, the warning would have to diagnose every conversion of a pointer to an integer except intptr_t (which might be useful to some but not others). I don't think it would be appropriate to make these implementation choices on a case-by-case basis and have GCC behave differently for one set of constructs or functions than another. Doing so would only result in inconsistencies and make the warnings less useful, not more.