Re: Trouble with alloca.h

Keith Marshall <[email protected]>
Newsgroups gmane.comp.gnu.mingw.user
Organization MinGW.org Project
Message-ID <5C69ED5C.4080606__1877.24305303476$1550446045$gmane$org@users.osdn.me>
On 17/02/19 17:17, Eli Zaretskii wrote:
> The new header alloca.h defines 'alloca' unconditionally as (AFAIU) an
> inline function:
> 
>   __CRT_ALIAS void *alloca( size_t __n )
>   { return __builtin_alloca( __n ); }

Yes, that's an inline function, which is *always* expanded in-line;
according to GCC's info, this makes it equivalent to a macro, in terms
of both speed, and code size.  However, it also has advantages over a
macro, in terms of type safety, (maybe not so important in this case,
because __builtin_alloca() should be type safe anyway), but rather more
importantly here, it also supports C++ namespace qualification, (which a
macro does not), should any user wish to so qualify it.

> This caused me trouble while building a GNU package, because Gnulib's
> alloca.h makes 'alloca' a macro:
> 
>   #ifndef alloca
>   # ifdef __GNUC__
>   #  define alloca __builtin_alloca

So, yet another endemic Gnulib bug.

> I'm not yet sure why Gnulib decides that it needs to use its own
> alloca.h,

It should not do so; it should defer to the host platform's own
implementation, when one is provided.

> but I know that many packages do the above regardless, when
> the compiler is GCC.

And such packages are similarly broken.

> Should MinGW's alloca.h perhaps be more defensive,

It could be, but...

> and only define its
> own version if 'alloca' is not already defined as a macro?

this isn't the way; it should simply, and unilaterally, override the
endemic brain damage in packages such as Gnulib, and just #undef any
pre-existing, conflicting macro definition.

-- 
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F

_______________________________________________
MinGW-Users mailing list
[email protected]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.osdn.me/mailman/listinfo/mingw-users
Also: mailto:[email protected]?subject=unsubscribe
signature.asc (application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)

iQIcBAEBAgAGBQJcae1dAAoJEMCtNsY0flo/tBUP/3trD6iUnRKJ0Vl3iTdS4bQg
EDp2cjdf60TgCrMpXQA+f497EoqGq/iRQd37TGzhxHhIz1DCDoq0ZpLA5Hr7+i8S
3d/fZVFcfkGiyMIXI1Osvs6xDkQpLR3Z3Rc+Il/8nhdpKDX0hmdQu0XXni3DYeMM
TG8uPLjwBk6LzX1U5hdYPEzdKnxtZgPsIMkbE4ByPcBkTLJA/XF9HARlZe5Y5UU9
mA+g87g1FbPmKZobCoh3Zv9DlHRPBitBE+Te5zuHYPpit6Pi8NtqTOU298eCq2+q
3nMsTYhJjEDaRRxPSl7wT7ACMJh44ZtbO/mSfob7Y+U9OMJ94XPQ65VbZ81cEM39
ySUDKeKjzj8SFfPebbH7r3yhnvJ0kCur4dl8jAz/zdG0KbCDkT3VyAS4r/CH1zgD
dqWcRqLrCuzWODb/1OW+rB7UVt83FaG7u2gcUAsFnviIwWdQp+29ODauDpqjk6rs
Psx/wIET6pykr6gbhpzopBDjFE/uvk6R+pln02HwdrwY1jQnf6SCWMiGmC2rJNop
67RroLLB6Ew0k90vNxLLsCmSmJd978+IWqlfcvF5323V3ml3D7WiYLtqeql2SHkO
f11L5XisiSk9vtIvjapJq3M/wlMwvK+WW15AYhwH6/XtwAMxnDao310TGXS5UNjr
0t2fADxdUsRoQ4yfoDPf
=o5mz
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.