From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <33b72a69832f3b5442b659b76e41a8a7@brasstown.quanstro.net> Date: Mon, 18 Feb 2013 14:38:03 +0000 Message-ID: From: Charles Forsyth To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=089e010d84ec2e7aae04d600ac10 Subject: Re: [9fans] c compiler bug Topicbox-Message-UUID: 1921f832-ead8-11e9-9d60-3106f5b1d025 --089e010d84ec2e7aae04d600ac10 Content-Type: text/plain; charset=UTF-8 On 18 February 2013 13:02, Comeau At9Fans wrote: > seems to be doing is setting up allowing the call to compile and once that > is satisfied then the subsequent definition "has" to match it, as perhaps a > way to do type punning. No, the compiler is simply applying scope rules. Without that inner declaration explicitly overriding the outer declaration--whether static or extern is used-- it will not compile (eg, if you put "static void fn(Outer*);" or "extern void fn(Outer*);" and remove static from fn in the file scope). The behaviour is undefined in ANSI C if two declarations that refer to the same object or function do not have compatible types (normally, you're protected by another rule that you can't have incompatible declarations *in the same scope*). ANSI C does, however, forbid the inner static declaration (which surprised me) "The declaration of an identifier for a function that has block scope shall have no explicit storage-class specifier other than extern." (6.7.1) --089e010d84ec2e7aae04d600ac10 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

The b= ehaviour is undefined in ANSI C if two declarations that refer to the same = object or function do not have compatible types
(normally, you're protected by another rule that you can't have inc= ompatible declarations *in the same scope*).

ANSI C does, however, forbid the inn= er static declaration (which surprised me)
"The declaration of an identifier for a fun= ction that has block scope shall have no explicit storage-class specifier o= ther than extern." (6.7.1)

<= /div>
--089e010d84ec2e7aae04d600ac10--