Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: gcc and 'include'
Date: Thu, 26 Mar 2026 19:08:16 -0700
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <86wlyy2fe7.fsf@linuxsc.com>
References: <10q4ceb$38i2d$1@dont-email.me> <20260327041042.00006946@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Fri, 27 Mar 2026 02:08:17 +0000 (UTC)
Injection-Info: dont-email.me; posting-host="606171d349eb5423921af05ed404581c"; logging-data="3543807"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JysMBigAhQ+1vMkhi8IyOdsUCdNJ9vLI="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:U6Q/TOXy8/rcrDjKL2wG+cJR150= sha1:0msMrgn5DE3/grHgsdF+Btw5VWE=
Xref: csiph.com comp.lang.c:397211
Michael S writes:
> On Thu, 26 Mar 2026 22:36:59 +0000
> Bart wrote:
>
>> Take this program:
>>
>> #include
>>
>> inline int F(){return rand();}
>>
>> int main(void) {
>> return F();
>> }
>>
>> This compiles fine with gcc using -O1 -O2 -O3.
>>
>> But compile without optimising, and it fails to link as it can't find
>> a function 'F'.
>>
>> Is it supposed to behave like that? I assume no discrete function F
>> is being generated because of the 'inline' attribute, but you'd think
>> it would ignore that if inlining wasn't enabled.
>>
>> [...]
>
> Sounds like a bug introduced during transition to c99/gnu99
> front end.
> With gcc4.x, which defaults to gnu89 it still works.
> Also works with the latest gcc -std=gnu89
> But there is no hope that gcc maintaines will ever admit that it is a
> bug.
It isn't a bug. The C standard allows this behavior.