From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,de8312f092ea7867 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!s15g2000yqm.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: YACT (Yet Another C Trap) Date: Mon, 30 Aug 2010 00:52:26 -0700 (PDT) Organization: http://groups.google.com Message-ID: <8c1b1776-6293-4663-ae65-32c667c3acc3@s15g2000yqm.googlegroups.com> References: <338f4d05-5b3b-47bd-bff8-76c1488eae6d@x42g2000yqx.googlegroups.com> NNTP-Posting-Host: 137.138.182.236 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1283154746 10871 127.0.0.1 (30 Aug 2010 07:52:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 30 Aug 2010 07:52:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s15g2000yqm.googlegroups.com; posting-host=137.138.182.236; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.7) Gecko/20100713 Firefox/3.6.7,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:13838 Date: 2010-08-30T00:52:26-07:00 List-Id: On 30 Sie, 10:21, stefan-lu...@see-the.signature wrote: > I tried it out. The above example gives an error. But the following > program compiles without warnings with gcc: > > #include > int main (int argc, char **argv) > { float x; > > =A0 =A0 x =3D 12,3; > Is this a language flaw of C, or a bug in gcc? It is a language flaw for two reasons: one is that the language should not allow you to initialize floating-point values with integers and the other is that the comma operator for fundamental types is nonsense [*]. :-) [*] But there are quite nice ways to use it for custom types. In any case, the above code violates the coding standard that discourages the use of unnamed numeric constants. Constants should be named (with notable exception of 0 and 1), which would bring you back to compile-time error. You might still argue that the need for such a coding standard indicates a flaw in the language anyway. Note that the above problem has many more interesting implications, especially when combined with other flaws: float f =3D 10.0f; f =3D f * 1,5; Go figure what it does (and I can bet that your guess will be wrong). ;-) -- Maciej Sobczak * http://www.inspirel.com YAMI4 - Messaging Solution for Distributed Systems http://www.inspirel.com/yami4