This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH]: New warning option -Walloca
On 8/31/07, Kaveh R. GHAZI <ghazi@caip.rutgers.edu> wrote:
> On Fri, 31 Aug 2007, Raksit Ashok wrote:
>
> > > > > 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.
> > > >
> > >
> > > Manuel> But then you won't get any warning when you use alloca through
> > > Manuel> another function or through a macro redefinition. Is that what you
> > > Manuel> really want?
> >
> > If we could poison alloca, and ignore alloca's in system headers (for
> > example, by making "poison alloca" a warning, and using
> > -Wno-system-headers), we would miss cases where alloca is used thru
> > another function or macro in system headers.
>
> A simpler approach would be to define alloca to something else *after* you
> include system headers. E.g.:
>
> #define alloca dont_use_alloca
>
> Then any time someone uses alloca they get spanked by the compiler and/or
> linker. This is stronger than poisoning because it affects the alloca
> calls that appear through macro expansions. You can do this in a common
> header included across the whole project. Each approach (poison vs macro)
> has its uses.
This would work if your codebase has a common header
that every file (both the source and the header files) includes
before including anything else.
But most large projects (e.g. gcc) don't have such one,
or it's very difficult to ensure such a guarantee.
Seongbae