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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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-7-bit Path: g2news1.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!newshosting.com!198.186.194.250.MISMATCH!news-xxxfer.readnews.com!news-out.readnews.com!postnews3.readnews.com!not-for-mail Date: Mon, 30 Aug 2010 06:13:50 -0400 From: "Peter C. Chapin" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: YACT (Yet Another C Trap) References: <338f4d05-5b3b-47bd-bff8-76c1488eae6d@x42g2000yqx.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4c7b84a6$0$2375$4d3efbfe@news.sover.net> Organization: SoVerNet (sover.net) NNTP-Posting-Host: 9b698d2d.news.sover.net X-Trace: DXC=VTIOoW;`PGfZ=N]>\A8jdhK6_LM2JZB_c7AN`KiBGR^c:WUUlR<856o;6V_LWd:``im On 2010-08-30 04:28, stefan-lucks@see-the.signature wrote: > P.S.: Even gcc -Wall doesn't warn about the flawed ",". It just tells me > "control reaches end of non-void function" (my main function should return > an integer, but it doesn't). In the expression statement x = 12,3; first 12 is assigned to x and then the expression '3' is evaluated, the result of which is ignored. It has a similar effect to x = 12; 3; except that it is one statement instead of two. The key point here is that the comma operator has lower precedence than even assignment. In C a statement can just be an expression followed by a semicolon. Since it is legal to write expressions that have no side effects you can do things like a + b; Given your original code ('x = 12,3') the Open Watcom C compiler issues the warning, "Expression is only useful for its side effects." It's a strange warning in some ways since the problem here is that the expression in question ('3') has no side effects. Ada avoids these problems because in Ada you can't just put a semicolon at the end of an expression to make a statement (assignment isn't an operator in Ada). Peter