This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: New warning option -Walloca


> Manuel> On the contrary, I suppose it will work if you poison the identifier
> Manuel> before including any system headers. Doesn't it?
>
> Tom> I believe this will give an error if a system header even declares
> Tom> alloca.  That's a bit unfriendly, since most users won't have control
> Tom> over these headers.

Yes, even declarations would cause an error:
----
# cat -n t.cc
    1  #pragma GCC poison alloca
    2  #include <alloca.h>
# g++ -c t.cc
In file included from t.cc:2:
/usr/include/alloca.h:30:8: error: attempt to use poisoned "alloca"
/usr/include/alloca.h:33:14: error: attempt to use poisoned "alloca"
/usr/include/alloca.h:36:10: error: attempt to use poisoned "alloca"
#
----
Furthermore, stdlib.h and regexp.h both include alloca.h.
The Walloca patch shouldn't emit warnings in the above cases. However,
it would emit warnings for methods of templated classes that are never
instantiated, as well as inline functions which are never used, etc..
And some templates in C++ system headers do use
alloca/__builtin_alloca.

We could defer the alloca warnings to a later stage, for example, when
code is emitted. Alternatively, what Dave suggested:

> Dave> Well, there's a thought: maybe poison should behave like warnings (i.e.
> Dave> be suppressed for the most part) when it comes to system headers?

This sounds like it would work too.

cheers,
-raksit


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]