Re: anonymous unions (C11)

From: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: anonymous unions (C11)
Date: 2025-09-30 11:21:51
Message-ID: CAExHW5vWabZz=snPka=ZxR=ik-drRW_NjZmtw_F5Yr3EVbHGDQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 24, 2025 at 4:49 AM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
>
> On Tue, Sep 23, 2025 at 5:38 PM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>>
>>
>>
>> That said, I did go overboard here and converted all the struct/union
>> combinations I could find, but I'm not necessarily proposing to apply
>> all of them. I'm proposing patches 0001 through 0004, which are
>> relatively simple or in areas that have already changed a few times
>> recently (so backpatching would not be trivial anyway), and/or they
>> are somewhat close to my heart because they originally motivated this
>> work a long time ago. But if someone finds among the other patches
>> one that they particularly like, we could add that one as well.
>
>
> I went through all commits and code changes are neat and clear.
>
> But when I tried to build on my Macbook M4, it got 18 errors against cryptohash.c:
> ```
> cryptohash.c:108:22: error: no member named 'data' in 'struct pg_cryptohash_ctx'
> 108 | pg_md5_init(&ctx->data.md5);
> | ~~~ ^
... snip ...
> cryptohash.c:225:26: error: no member named 'data' in 'struct pg_cryptohash_ctx'
> 225 | pg_sha512_final(&ctx->data.sha512, dest);
> | ~~~ ^
> 18 errors generated.

I am using meson and gcc with following versions

$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ meson --version
0.61.2

I am getting opposite of those errors

../../coderoot/pg/src/common/cryptohash.c: In function ‘pg_cryptohash_init’:
../../coderoot/pg/src/common/cryptohash.c:108:41: error:
‘pg_cryptohash_ctx’ has no member named ‘md5’
108 | pg_md5_init(&ctx->md5);
| ^~
... snip ...
../../coderoot/pg/src/common/cryptohash.c:225:45: error:
‘pg_cryptohash_ctx’ has no member named ‘sha512’
225 | pg_sha512_final(&ctx->sha512, dest);

Attached patch fixes those errors for me.

--
Best Wishes,
Ashutosh Bapat

Attachment Content-Type Size
make_union_anonymous.patch text/x-patch 306 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2025-09-30 11:25:28 Re: Wordsmith pgstat_relation.c header comment
Previous Message Álvaro Herrera 2025-09-30 11:16:50 Re: allow benign typedef redefinitions (C11)