Re: [PATCH v7 14/16] reftable: make reftable_record a tagged union
- From
Han-Wen Nienhuys <hanwen@google.com>
- Date
- Jan 24, 2022, 19:53 UTC
- Message-ID
- <CAFQ2z_M7s9Y_FH5x+qJxyZO0iHq+b_mf8=-dKcmADzFEoGLJUg@mail.gmail.com>
- In-Reply-To
- <220124.86ilu8hqag.gmgdl@evledraar.gmail.com>
On Mon, Jan 24, 2022 at 8:44 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 9 quoted lines
> I didn't test the v6 on xlc on AIX 7.1, but found that it refuses to > compile this code (but the one on AIX 7.2 is OK with it): > > "reftable/generic.c", line 135.26: 1506-196 (S) Initialization between types "char*" and "struct reftable_ref_record" is not allowed. > "reftable/generic.c", line 147.26: 1506-196 (S) Initialization between types "char*" and "struct reftable_log_record" is not allowed. > "reftable/writer.c", line 261.26: 1506-196 (S) Initialization between types "char*" and "struct reftable_ref_record" is not allowed. > "reftable/writer.c", line 312.26: 1506-196 (S) Initialization between types "char*" and "struct reftable_log_record" is not allowed. > "reftable/writer.c", line 406.45: 1506-196 (S) Initialization between types "unsigned long long" and "struct reftable_index_record" is not allowed. >
> I.e. you're dereferencing a struct type here to get at its first member,
No, that's not what I'm doing.
> > + struct reftable_record rec = {
> > + .type = BLOCK_TYPE_REF,
> > + .u.ref = *ref,
> > + };reftable_record is tagged union, and u.ref is a reftable_ref_record. I intend to shallow-copying the parameter (a reftable_record called 'ref') into 'rec.u.ref' , precisely as it is written.
Does this patch pass the unittests?
-- Han-Wen Nienhuys - Google Munich I work 80%. Don't expect answers from me on Fridays. -- Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Paul Manicle, Halimah DeLaine Prado