On Thu, Feb 2, 2012 at 4:10 PM, Marc Lehmann <[email protected]> wrote: >> Hmm, you're right, although I'm not sure about portability (even >> though I code in C I never actually read the standard, so I don't >> really know what's supposed to happen here). > Well, the right thing obviously (6.9.1 External object definitions). It's > portable to every C compiler, something which clang is relatively far > away, which is why it isn't worth supporting it yet, it's just too buggy > (being so young, thats somewhat expected).
Thank you very much for this reference. I was finally able to find and read http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf (which is the latest C99 draft). Although the section is 6.9.2 (maybe I found the wrong standard?) and it says: 1. If the declaration of an identifier for an object has file scope and an initializer, the declaration is an external definition for the identifier. 2. A declaration of an identifier for an object that has file scope without an initializer, and without a storage-class specifier or with the storage-class specifier static, constitutes a tentative definition. [...] If I understood it all correctly, according to 2 the first `static int var' would be a tentative definition, and according to 1 the last `static int var = 0' would make it an external definition with linkage internal. However, `extern int var' inside a function wouldn't be a tentative definition, and would have linkage external. Now, according to 6.2.2: 7. If, within a translation unit, the same identifier appears with both internal and external linkage, the behavior is undefined. I was thinking that by reading standard I would maybe find basis for a good bug report to clang, but now I am totally confused. :-/ Do you think maybe clang follows standard here (by giving an error for an undefined behavior) after all, or is there a bug after all? (in which case I would be happy to file a bug report) P.S. Also, reading your reply, I once again feel like I inadvertently offended you somehow (by my lack of proper knowledge perhaps?), and for that I am very sorry. I'm just trying to help in any way I could, especially for an OS that I love. (for me it doesn't matter if a corporation behind Mac OS X is evil or not, it makes a beautiful unix-based operating system, and for that I am grateful) _______________________________________________ libev mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
