Re: [HACKERS] Compiler warning in costsize.c - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Compiler warning in costsize.c
Date
Msg-id 20257.1491825923@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] Compiler warning in costsize.c  (David Rowley <david.rowley@2ndquadrant.com>)
Responses Re: [HACKERS] Compiler warning in costsize.c  (Michael Paquier <michael.paquier@gmail.com>)
Re: [HACKERS] Compiler warning in costsize.c  (ilmari@ilmari.org (Dagfinn Ilmari Mannsåker))
List pgsql-hackers
David Rowley <david.rowley@2ndquadrant.com> writes:
> On 8 April 2017 at 04:42, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> BTW, is it really true that only these two places produce such warnings
>> on MSVC?  I see about three dozen uses of PG_USED_FOR_ASSERTS_ONLY in our
>> tree, and I'd have expected all of those places to be causing warnings on
>> a compiler that doesn't have a way to understand that annotation.

> Seems that MSVC is happy once the variable is assigned, and does not
> bother checking if the variable is used after being assigned, whereas,
> some other compilers might see the variable as uselessly assigned.

> At the moment there are no other warnings from MSVC since all the
> other places the variable gets assigned a value in some code path.

I wonder if we shouldn't just do
    RangeTblEntry *rte PG_USED_FOR_ASSERTS_ONLY;    ListCell   *lc;    /* Should only be applied to base relations that
aresubqueries */    Assert(rel->relid > 0);
 
-#ifdef USE_ASSERT_CHECKING    rte = planner_rt_fetch(rel->relid, root);    Assert(rte->rtekind == RTE_SUBQUERY);
-#endif

and eat the "useless" calculation of rte.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Andrew Borodin
Date:
Subject: [HACKERS] Merge join for GiST
Next
From: Michael Paquier
Date:
Subject: Re: [HACKERS] src/interfaces/libpq shipping nmake-related Makefiles