[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Caveat with lua_pushlightuserdata(L, (void *)&key)
- From: Mike Pall <mikelu-0606@...>
- Date: Tue, 27 Jun 2006 16:35:53 +0200
Hi,
Roberto Ierusalimschy wrote:
> I think the C standard is clear about that (no linkage between different
> identifiers). This is a bug in GCC.
I'm not so sure it's GCC. It doesn't happen here on Linux with
any GCC version I've tried (3.3, 3.4, 4.1).
The bug might be just in the specific (heavily-patched) GCC 4.0
Apple is using. Or only in combination with the Mach linker.
Here's a trivial test program:
#include <stdio.h>
static const int regkey_foo = 1;
static const int regkey_bar = 1;
int main(int argc, char **argv)
{
printf("%p %p\n", ®key_foo, ®key_bar);
return 0;
}
Note: It must be compiled with optimization on.
It _should_ print two different numbers. If it doesn't, then
(according to Roberto) the toolchain is non-standards compliant.
I've verified it's ok on various Linux, *BSD or Solaris hosts
with various GCC and linker versions and variants.
It would be interesting if someone with access to a few different
Mac OS X versions (PPC and/or Intel Macs) could try this. Please
include the OS, GCC and linker versions. Maybe try this with and
without optimization. Or try -std=c89 or -std=c99 to enforce a
particular standard and see whether it happens, too.
If a pattern emerges then we could file a bug report with either
Apple or the GCC team.
Bye,
Mike
- References:
- Caveat with lua_pushlightuserdata(L, (void *)&key), Mike Pall
- Re: Caveat with lua_pushlightuserdata(L, (void *)&key), Julien Cugnière
- Re: Caveat with lua_pushlightuserdata(L, (void *)&key), Andreas Stenius
- Re: Caveat with lua_pushlightuserdata(L, (void *)&key), David Jones
- Re: Caveat with lua_pushlightuserdata(L, (void *)&key), Glenn Maynard
- Re: Caveat with lua_pushlightuserdata(L, (void *)&key), Roberto Ierusalimschy