Dave Korn wrote: > ELF GAS/LD seem happy enough when presented with a ".comm foo,0" directive, > but PE does rather literally what you asked, and gives you no data object, > leading to i0 in the above being an undefined reference at link time.
After a bit further digging, it turns out that this is because PE uses the same representation for an external symbol as would represent a common of size 0, so if you define such a common, it magically becomes an undefined external symbol instead! Owing to lack of support for alignment of common symbols in PE, we've been rounding all sizes up to a multiple of 16 until now, including zero, which has hidden this problem from arising. In the patch I just posted at http://gcc.gnu.org/ml/gcc-patches/2009-05/msg01528.html we can now align common symbols, so we don't round any more - and thus get an actual zero-sized symbol definition passed to the assembler for the first time. I do think we probably ought to be erroring about this on both platforms, shouldn't we? I can always hack the output routine to (for example) use one unit of the alignment size as the minimum to work around this problem and let the testcase run, but I wonder if a warning is getting lost somewhere owing to array->pointer flattening? cheers, DaveK