Re: [PATCH] reftable tests: use C syntax compatible with old xlc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Han-Wen Nienhuys <hanwen@xxxxxxxxxx> writes:

> On Thu, Jan 13, 2022 at 12:38 PM Ævar Arnfjörð Bjarmason
> <avarab@xxxxxxxxx> wrote:
>> Change code added in 1ae2b8cda84 (reftable: add merged table view,
>> 2021-10-07) to be compatible with older versions of AIX's IBM xlc
>> compiler. Version V12.1 of it (on gcc111.fsffrance.org) will hard
>> error with:
>>
>>     "reftable/merged_test.c", line 211.19: 1506-196 (S) Initialization between types "char*" and "struct reftable_ref_record" is not allowed.
> ...
> Weird. What C standard does xlc implement?

Interesting.  It is complaining about this thing:

	struct reftable_ref_record r2[] = { {
		.refname = "a",
		.update_index = 2,
		.value_type = REFTABLE_REF_DELETION,
	} };
	...
	struct reftable_ref_record want[] = {
		r2[0],
		r1[1],
		r3[0],
		r3[1],
	};

and somehow assuming that r2[0] corresponds to the first member of a
"struct reftable_ref_record" structure, which is "char *refname".
Of course, you cannot initialize a character pointer with a whole
struct, which is *not* what the code wants to do.  I would
understand if it were written incorrectly like so

BAD:	struct reftable_ref_record want[] = {
BAD:		{ r2[0] },
BAD:		{ r1[1] },
BAD:		{ r3[0] },
BAD:		{ r3[1] },
BAD:	};

but that is not what we fed the compiler.  But apparently the
compiler is confused.

I wonder if it helps to use designated initializer on the latter, i.e.

	struct reftable_ref_record want[] = {
		[0] = r2[0],
		[1] = r1[1],
		[2] = r3[0],
		[3] = r3[1],
	};





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux