Deutsch   English   Français   Italiano  
<87cyocy9ls.fsf@nosuchdomain.example.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!feed.opticnetworks.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: Whaddaya think?
Date: Wed, 19 Jun 2024 13:13:19 -0700
Organization: None to speak of
Lines: 47
Message-ID: <87cyocy9ls.fsf@nosuchdomain.example.com>
References: <666ded36$0$958$882e4bbb@reader.netnews.com>
	<20240616015649.000051a0@yahoo.com> <v4lm16$3s87h$4@dont-email.me>
	<v4lmso$3sl7n$1@dont-email.me> <v4lr0m$3tbpj$1@dont-email.me>
	<8734pd4g3s.fsf@nosuchdomain.example.com>
	<v4ltuj$3trj2$1@dont-email.me>
	<87y17530a0.fsf@nosuchdomain.example.com> <v4mb92$3ak$1@dont-email.me>
	<87tths39yy.fsf@nosuchdomain.example.com>
	<v4oi9f$gnf3$1@dont-email.me>
	<877ceo2iqq.fsf@nosuchdomain.example.com>
	<v4onrg$hmc2$1@dont-email.me>
	<87plsf17q1.fsf@nosuchdomain.example.com>
	<87plsdy9aj.fsf@nosuchdomain.example.com>
	<v4u2kl$1rslf$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Wed, 19 Jun 2024 22:13:24 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="14c46e9d4441e9b6d7e573ea203ad727";
	logging-data="2258878"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX191F7/wWzVsettYoBAo15dC"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:yqvhfOYEHs+Yw0qXcmULx3PqnUM=
	sha1:mUxI2BBNVMD4Gn6Fmt5YdKXX9tQ=
Bytes: 3567

David Brown <david.brown@hesbynett.no> writes:
> On 19/06/2024 04:07, Keith Thompson wrote:
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> [...]
>>> That's fine.  A return statement or exit() call is unnecessary
>>> in main() due to a special-case rule that was added in 1999 for
>>> compatibility with C++.  I don't particularly like that rule myself.
>>> I choose to omit the return statement in small programs, but if
>>> you want to add the "return 0;", I have absolutely no objection.
>>> (I used to do that myself.)  It even makes your code more portable
>>> to old compilers that support C90.  (tcc claims to support C99,
>>> but it has a bug in this area.)
>> A minor point: The latest unreleased version of tcc appears to fix
>> this bug.  In tcc 0.9.27, falling off the end of main (defined as
>> "int main(void)") returns some random status.  In the latest version,
>> it returns 0, based on a quick experiment and a cursory examination
>> of the generated object code.  (tcc doesn't have an option to
>> generate an assembly listing; I used "tcc -c" followed by "objdump
>> -d".)
>> 
>
> Godbolt has support for tcc, which might be convenient if you want to
> look at its output.
>
> <https://godbolt.org/z/5hK7PbGbj>

If anyone cares, I found the git commit where this was fixed:

commit 3b9c3fd1860ceaa5684d5837455084707a7848c9
Author: Michael Matz <matz@suse.de>
Date:   2018-11-03 22:17:20 +0100

    Fix noreturn in main()

    ISO C requires 'main' falling through the end without explicit
    returns to implicitely return 0 (if declared as returning int).

The most recent release of tcc is 0.9.27, released 2017-12-17.
But the git repo (<git://repo.or.cz/tinycc.git>, mirror at
<https://github.com/TinyCC/tinycc> has updates as recently as
2024-03-22.  Post-0.9.27 updates are on the "mob" branch.

Godbolt's "TCC (trunk)" is built from the latest version in git.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */