bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gnulib's alloca.h used even when there is a system header


From: Bruno Haible
Subject: Re: Gnulib's alloca.h used even when there is a system header
Date: Tue, 19 Feb 2019 00:32:24 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )

Hi Eli,

>      ./alloca.h:40:18: error: inlining failed in call to always_inline 
> '__builtin_alloca': function not considered for inlining
>       #  define alloca __builtin_alloca
>                      ^

GCC never inlines a function that calls alloca() or __builtin_alloca().
The reason is that if you call this function in a loop, then without
inlining it will consume a bounded amount of stack whereas with inlining
it might cause a stack overflow.

The mingw people have declared their new alloca() function as "always
inline", and GCC is decent enough to point us to the dilemma that it
cannot resolve.

Of course, removing the always-inline marker would not help: alloca(N)
would then return an address that is approximately N bytes below the
stack pointer, that is, which points to an area that gets randomly
overwritten (when a signal comes in).

The upshot is: you can't define an alloca() function this way.
Either define it as a macro - which is what the gnulib override does,
if it gets activated -, or define it as a function in assembly-language.

Since you say that this is a fresh bug from mingw, it's probably best
that it gets reported to the mingw people. Then we don't need a Gnulib
workaround.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]