Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: gcc failure (optimised/non-optimised) Date: Sun, 30 Apr 2017 11:24:47 -0700 Organization: None to speak of Lines: 23 Message-ID: References: <58fb2265.5246218@news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="518c2254bac820b1cb24a1d9d6a93e31"; logging-data="23057"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+DF4QEEYV+1F1pQdCQDPL" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:g0CtcW8XQVYeeoXQNv4W+WdnL/Y= sha1:WW5vfit1Hg+crH9bVfqM5Dqibc8= Xref: csiph.com comp.lang.c:108788 Noob writes: [...] > Let's consider a slightly different situation. > > int foo(int n) { > return n * 2 / 2; > } > > Does anyone disagree that an optimizing compiler would > determine that this is the identity function, and would > drop the calls altogether, by replacing foo(x) with x. I agree that an optimizing compiler (actually any compiler) *could* do that, given that x is of type int. But there is no requirement to do so. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"