Deutsch English Français Italiano |
<20241204153638.0000105c@yahoo.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Michael S <already5chosen@yahoo.com> Newsgroups: comp.lang.c Subject: Re: question about linker Date: Wed, 4 Dec 2024 15:36:38 +0200 Organization: A noiseless patient Spider Lines: 80 Message-ID: <20241204153638.0000105c@yahoo.com> References: <vi54e9$3ie0o$1@dont-email.me> <20241129142810.00007920@yahoo.com> <vicfra$13nl4$1@dont-email.me> <20241129161517.000010b8@yahoo.com> <vicque$15ium$2@dont-email.me> <vid110$16hte$1@dont-email.me> <87mshhsrr0.fsf@nosuchdomain.example.com> <vidd2a$18k9j$1@dont-email.me> <8734j9sj0f.fsf@nosuchdomain.example.com> <vihhkj$2er60$1@dont-email.me> <vihjaj$2f79m$2@dont-email.me> <vihs4s$2hgg1$2@dont-email.me> <20241201185740.00004c30@yahoo.com> <viia55$2mrc9$1@dont-email.me> <vinftq$2sv5n$1@paganini.bofh.team> <20241204135653.00004f01@yahoo.com> <viph5p$rjqn$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Wed, 04 Dec 2024 14:35:47 +0100 (CET) Injection-Info: dont-email.me; posting-host="1a483ca7e101f9d13f54e5e199a72345"; logging-data="866985"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+adv01vPbdFdGUt5n7eLmMtkP0vrTTmgo=" Cancel-Lock: sha1:+i6dAikspqimHO5ow4XQyUdL61c= X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32) Bytes: 4597 On Wed, 4 Dec 2024 13:15:53 +0100 David Brown <david.brown@hesbynett.no> wrote: > On 04/12/2024 12:56, Michael S wrote: > > On Tue, 3 Dec 2024 17:42:20 -0000 (UTC) > > antispam@fricas.org (Waldek Hebisch) wrote: > > > >> David Brown <david.brown@hesbynett.no> wrote: > >>> On 01/12/2024 17:57, Michael S wrote: > >>>> On Sun, 1 Dec 2024 15:34:04 +0100 > >>>> David Brown <david.brown@hesbynett.no> wrote: > >>>>> > >>>>> I can see some advantages in a language being happy with any > >>>>> order of function definition, without requiring forward > >>>>> declarations to use a function before it is defined. But C is > >>>>> not like that, and I cannot honestly say it bothers me one way > >>>>> or the other. And apparently, it does not particularly bother > >>>>> many people - there is, I think, no serious impediment or > >>>>> backwards compatibility issue that would prevent C being > >>>>> changed in this way. Yet no one has felt the need for it - at > >>>>> least not strongly enough to fight for it going in the standard > >>>>> or being a common compiler extension. > >>>>> > >>>>> > >>>>> > >>>> > >>>> I think, arguing in favor of such change would be easier on top > >>>> of the changes made in C23. > >>>> Before C23 there were, as you put it "no serious impediment or > >>>> backwards compatibility issue". After C23 we could more > >>>> categorical claim that there are no new issues. > >>>> > >>> > >>> Does that mean there was something that you think was allowed in C > >>> before C23, but not after C23, that would potentially be a problem > >>> here? > >>> > >>> What, specifically, are you thinking of? > >> > >> Michael probably meant 'constexpr'. > > > > No, I am afraid of cases where function is used without prototype > > and then there is conflicting definition later in the module. > > Of course, it's UB, but in practice it could often work fine. > > Something like that: > > > > static int bar(); > > int foo(void) > > { > > return bar(42); > > } > > > > static int bar(int a, int b) > > { > > if (a == 42) > > return -1; > > return a - b; > > } > > > > > > Under c23 rules the code above is illegal, but before c23 it's > > merely a UB. > > > > I think it is always better to have a hard error than to allow UB! > > But this is not actually anything to do with ordering of functions or > declarations. You could omit "foo" entirely and the code is still an > error in C23, because "static int bar();" /is/ a prototype > declaration in C23 - it means the same as "static int bar(void);". > In case you lost the context, in the post above I am explaining why I think that the suggested change that turns any static function definition into "retroactive" module-scale prototype declaration can potentially break working pre-C23 code. On the other hand, so far I was not able to imagine a case in which such change would break C23 code. And that is the reason why I think that the change is easier to introduce on top of C23.