From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by mx.groups.io with SMTP id smtpd.web09.4200.1624431289924000952 for ; Tue, 22 Jun 2021 23:54:50 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@posteo.de header.s=2017 header.b=e1mHX6Ag; spf=pass (domain: posteo.de, ip: 185.67.36.65, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 6F921240028 for ; Wed, 23 Jun 2021 08:54:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1624431287; bh=Mya9RZGvkieEnn00rG1+mKM5a0wMfnIOpzlvu+C/74s=; h=Subject:To:Cc:From:Date:From; b=e1mHX6AgZGriOK+Hr2geOPFUJe9DaTxiKvFzbqX/1bnICgfHirr3tMs0FjRMU7khs Fmr1nFYlqaAbdyEZkE8LbDMdNB+FBShiUYOMfauh8pG3X0slx5+r8087+iSF6v8dYU feitMHR1dmO6L96geEgDCFXZK7UeTG6o6pAbHWV839hxbRUuuWR3S2H888sRncsxcE XEW8zNlhudttH2hvnBzudN508rN5TccpBtlE+Nos4ja17zdm02f8jLvVGBB1GLvjRg n2cEkeIEivhuf0RL2kUiAqX5T9ituHR2IKORqOjV33k8/xLLpvPCOk4T/tIkpItW/f 1fwfvHygo525g== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4G8vC66pXcz9rxT; Wed, 23 Jun 2021 08:54:42 +0200 (CEST) Subject: Re: [edk2-devel] [PATCH v1 0/5] EDK2 Code First: PI Specification: Update EFI_MM_COMMUNICATE_HEADER To: Laszlo Ersek , devel@edk2.groups.io, kuqin12@gmail.com Cc: Jian J Wang , Hao A Wu , Eric Dong , Ray Ni , Michael D Kinney , Liming Gao , Zhiguang Liu , Andrew Fish , Leif Lindholm References: <20210610014259.1151-1-kuqin12@gmail.com> <93fd191e-e62f-f02e-11d0-403173fcdf42@posteo.de> <817ab349-b7a2-528b-9b78-aa72cefcd25a@posteo.de> From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= Message-ID: <40bffd17-28a6-d280-02b1-628f1b2daa09@posteo.de> Date: Wed, 23 Jun 2021 06:54:42 +0000 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: quoted-printable On 22.06.21 17:34, Laszlo Ersek wrote: > On 06/18/21 11:37, Marvin H=C3=A4user wrote: >> On 16.06.21 22:58, Kun Qin wrote: >>> On 06/16/2021 00:02, Marvin H=C3=A4user wrote: >>>> 2) Is it feasible yet with the current set of supported compilers to >>>> support flexible arrays? >>> My impression is that flexible arrays are already supported (as seen >>> in UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkTypes.h). >>> Please correct me if I am wrong. >>> >>> Would you mind letting me know why this is applicable here? We are >>> trying to seek ideas on how to catch developer mistakes caused by thi= s >>> change. So any input is appreciated. >> Huh, interesting. Last time I tried I was told about incompatibilities >> with MSVC, but I know some have been dropped since then (2005 and 2008 >> if I recall correctly?), so that'd be great to allow globally. > I too am surprised to see > "UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkTypes.h". The > flexible array member is a C99 feature, and I didn't even know that we > disallowed it for the sake of particular VS toolchains -- I thought we > had a more general reason than just "not supported by VS versions X and= Y". > > The behavior of OFFSET_OF() would be interesting -- the OFFSET_OF() > macro definition for non-gcc / non-clang: > > #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field)) > > borders on undefined behavior as far as I can tell, so its behavior is > totally up to the compiler. It works thus far okay on Visual Studio, bu= t > I couldn't say if it extended correctly to flexible array members. Yes, it's UB by the standard, but this is actually how MS implements=20 them (or used to anyway?). I don't see why it'd cause issues with=20 flexible arrays, as only the start of the array is relevant (which is=20 constant for all instances of the structure no matter the amount of=20 elements actually stored). Any specific concern? If so, they could be=20 addressed by appropriate STATIC_ASSERTs. Best regards, Marvin > > Thanks > Laszlo > >> I feel >> like if the structure is modified anyway, it should probably get a >> trailing flexible array over the 1-sized hack. What do you think?