Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Bart Newsgroups: comp.lang.c Subject: Re: how cast works? Date: Sat, 10 Aug 2024 11:17:39 +0100 Organization: A noiseless patient Spider Lines: 30 Message-ID: References: <87ttfu94yv.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 10 Aug 2024 12:17:39 +0200 (CEST) Injection-Info: dont-email.me; posting-host="a0e251ad936bdebc4e157c2935c3fc38"; logging-data="589945"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PIeebzpP0eQ2SlTno+ijs" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:TE94t+b2tkTiR8IzAkNFZhuDTwY= In-Reply-To: Content-Language: en-GB Bytes: 2316 On 09/08/2024 21:01, David Brown wrote: > On 09/08/2024 20:54, Thiago Adams wrote: > I don't know what you are referring to here.  But if you are using > compiler explorer, I encourage you to look at the generated output for a > wide range of targets, including 8-bit AVR, 16-bit MSP430, 32-bit ARM, > and 64-bit x86.  Use gcc -O1 or -O2 in every case. When would you choose -O2 over -O1 or vice versa? Could a similar circumstance cause you to choose -O0? Why not -O3? In fact, why is there a -O0 option at all?   (Ignore Bart's > ignorant blatherings about optimisation.) [To TA:] Yes do. But don't complaint to me when your test code results in meaningless or misleading output, or no output at all. Actually, I would recommend looking at both (eg. -O0 and -O1) so that you can see if the compiler's optimiser has been over-zealous in eliminating code, or has chopped out key bits, so that you might modify your test code. I would recommend also looking at the Tiny C option on godbolt when comparing x86 code.