Re: tapeblocks is uninitialized in logtape.c

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: tapeblocks is uninitialized in logtape.c
Дата
Msg-id 12583.1518644953@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: tapeblocks is uninitialized in logtape.c  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Список pgsql-hackers
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> Tom Lane wrote:
>> Actually, on looking closer, it's more likely got something to do with
>> whether or not you used --enable-cassert.  If the Assert at the top of
>> the function is disabled, then IMO a compiler that failed to complain
>> about this coding would be pretty damn broken.

> I tried removing the Assert, and my compiler doesn't complain.  I
> noticed that the function is static and the only caller has its own
> assert about ntapes; yet removing that one doesn't cause a warning
> either.  I made the function non-static -- still no warning.

If I make the function non-static, I get a warning (note you can't
just remove the "static" on the function itself, you also have to
change the forward declaration earlier in the file).  Marking the
function pg_noinline also results in a warning.

It is darn weird that there's no warning after inlining --- the caller
is only asserting ntapes > 0, which is not strong enough to prove
that the loop must be iterated.  Moreover, I see the warning even
if I leave in the "Assert(lts->nTapes >= 2)" ... so my compiler, at
least, is not using those assertions to prove the loop must iterate.

I notice that, because "lt" is initialized to NULL, the compiler
might feel it can assume that the loop iterated at least once
if control gets to the use of tapeblocks.  But the whole thing
still seems weird.  I think we must be looking at some squishy
spots in gcc's rules about when to issue a warning.

            regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: FOR EACH ROW triggers on partitioned tables
Следующее
От: Tatsuo Ishii
Дата:
Сообщение: Re: Is this a bug?