lua-users home
lua-l archive

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


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", &regkey_foo, &regkey_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