From owner-freebsd-current@FreeBSD.ORG Mon Jul 30 07:12:13 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 402FB1065674; Mon, 30 Jul 2012 07:12:13 +0000 (UTC) (envelope-from lev@FreeBSD.org) Received: from onlyone.friendlyhosting.spb.ru (onlyone.friendlyhosting.spb.ru [IPv6:2a01:4f8:131:60a2::2]) by mx1.freebsd.org (Postfix) with ESMTP id C41838FC18; Mon, 30 Jul 2012 07:12:12 +0000 (UTC) Received: from lion.home.serebryakov.spb.ru (unknown [IPv6:2001:470:923f:1:9db0:4615:f8f5:e1a7]) (Authenticated sender: lev@serebryakov.spb.ru) by onlyone.friendlyhosting.spb.ru (Postfix) with ESMTPA id D24F74AC2D; Mon, 30 Jul 2012 11:12:10 +0400 (MSK) Date: Mon, 30 Jul 2012 11:12:09 +0400 From: Lev Serebryakov Organization: FreeBSD Project X-Priority: 3 (Normal) Message-ID: <492266872.20120730111209@serebryakov.spb.ru> To: Arnaud Lacombe In-Reply-To: References: <20120725155211.GA33971@onelab2.iet.unipi.it> <20120729095833.GB80946@onelab2.iet.unipi.it> <20120729191958.GB85015@onelab2.iet.unipi.it> <20120729204721.GA87481@onelab2.iet.unipi.it> <1119098728.20120730003000@serebryakov.spb.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: "Bjoern A. Zeeb" , Luigi Rizzo , current@freebsd.org, David Chisnall Subject: Re: RFC: libkern version of inet_ntoa_r X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: lev@FreeBSD.org List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2012 07:12:13 -0000 Hello, Arnaud. You wrote 30 =D0=B8=D1=8E=D0=BB=D1=8F 2012 =D0=B3., 2:30:21: >> It looks very gcc-ish. AL> could you back your point with a technical argument, please ? This AL> sounds rather FUD'ish so far. AL> The ({ ... }) is nothing more than a primary-expression enclosing a AL> compound-statement; And how will it return value? It is completely illegal for compound statement to return value. And to be a part of primary expression, too. Here is simple test: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 1 #include 2 #include 3 4 int fn(int x, int y) { return x + y; } 5 6 #define fn(x) ({ fn(x, 42); }) 7 8 int main(int argc, char *argv[]) { 9 printf("%d\n", fn(10)); 10 return 0; 11 } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D gcc compiles it and prints "52", but MSVC++ 10.0 cannot compile this at all, and it is in its own right: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D D:\home\lev\test>cl test.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 8= 0x86 Copyright (C) Microsoft Corporation. All rights reserved. test.c test.c(9) : error C2059: syntax error : '{' test.c(9) : error C2059: syntax error : ')' test.c(9) : error C2059: syntax error : ')' test.c(10) : error C2059: syntax error : 'return' test.c(11) : error C2059: syntax error : '}' =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D See http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html -- it is clearly marked as "GNU C" construct, not ANSI/ISO C/C++ one. And even more: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > gcc -Wall -ansi -pedantic -std=3Dc99 test.c test.c: In function 'main': test.c:9: warning: ISO C forbids braced-groups within expressions > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --=20 // Black Lion AKA Lev Serebryakov