From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [PATCHES] fix for strict-alias warnings |
Date: | 2003-10-11 23:03:13 |
Message-ID: | 3F888C31.70305@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
Bruce Momjian wrote:
>I understand the desire to deal with this later, but we never seem to
>focus on compiler issues except during beta.
>
>I think I know why we are hitting the warning in tablecmds.c and not in
>trigger.c. Trigger.c has:
>
> ExecCallTriggerFunc(TriggerData *trigdata,
> FmgrInfo *finfo,
> MemoryContext per_tuple_context)
> {
>
> ...
> fcinfo.flinfo = finfo;
> fcinfo.context = (Node *) trigdata;
>
>This does not generate a warning, while this does in tablecmds.c:
>
> while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
> {
> FunctionCallInfoData fcinfo;
> TriggerData trigdata;
>
> /*
> * Make a call to the trigger function
> *
> * No parameters are passed, but we do set a context
> */
> MemSet(&fcinfo, 0, sizeof(fcinfo));
>
> /*
> * We assume RI_FKey_check_ins won't look at flinfo...
> */
> trigdata.type = T_TriggerData;
> trigdata.tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW;
> trigdata.tg_relation = rel;
> trigdata.tg_trigtuple = tuple;
> trigdata.tg_newtuple = NULL;
> trigdata.tg_trigger = &trig;
>
> fcinfo.context = (Node *) &trigdata;
>
> RI_FKey_check_ins(&fcinfo);
> }
>
>trigger.c doesn't generate the warning because it is a TriggerData*,
>while tablecmds.c has an acual structure. trigger.c doesn't know if the
>passed pointer was allocated via malloc(), and therefore properly
>aligned for any data type, or if it was allocated on the stack, so it
>does not complain.
>
>
I could be wrong, but I don't think it has to do with malloc or whether
or not it is on the stack or in dynamic memory, but rather to do with
the fact that you have manipulated it using one personality and then
cast it to another.
>In tablecmds.c, they create it as local loop structure that is passed to
>RI_FKey_check_ins(). What we should be doing in this code is allocating
>a proper Node structure using makeNode(TriggerData), and using that in
>the loop. (We should allocate it outside the loop.)
>
>I see the same problem in execQual.c. sysv_shmem probably needs the
>void*, and psql/command.c should have parse_char defines as unsigned
>char **, rather than char **.
>
>
signedness is not supposed to affect strict aliasing, but the compiler
could be confused.
(disclaimer) I am not a language lawyer, and this is one of those rare
times we need one :-) Don't take my word for it on this stuff.
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | James Wilson | 2003-10-12 00:52:02 | Re: Hacking PostgreSQL to work in Mac OS X 10.3 (Panther 7B85) |
Previous Message | Bob Badour | 2003-10-11 21:53:37 | Re: Dreaming About Redesigning SQL |
From | Date | Subject | |
---|---|---|---|
Next Message | veramente@libero.it | 2003-10-12 14:06:59 | libpq Italian Version first translation |
Previous Message | Bruce Momjian | 2003-10-11 20:22:31 | Re: [PATCHES] fix for strict-alias warnings |