Re: Compiler warning when using TRGM_REGEXP_DEBUG

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sergei Kornilov <sk(at)zsrv(dot)org>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Compiler warning when using TRGM_REGEXP_DEBUG
Date: 2026-03-02 19:23:32
Message-ID: 866550.1772479412@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Sergei Kornilov <sk(at)zsrv(dot)org> writes:
> I was looking into how pg_trgm index support works with regular expressions. When building HEAD with the TRGM_REGEXP_DEBUG option, my compiler warns:

> trgm_regexp.c: In function ‘printSourceNFA’:
> trgm_regexp.c:2142:41: warning: declaration of ‘i’ shadows a previous local [-Wshadow=compatible-local]
> 2142 | int i,
> | ^
> trgm_regexp.c:2133:33: note: shadowed declaration is here
> 2133 | int i;

Ah, yeah, I see it too with -DTRGM_REGEXP_DEBUG.

> Does it make sense to fix this warning? It is possible to either rename this variable or remove the second declaration (the variable is used in another loop after this code).

I think if we need to touch it, we should modernize all the loops in
this function to use loop-local variables. Will see to it.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ilia Evdokimov 2026-03-02 19:28:59 Re: V18 change on EXPLAIN ANALYZE
Previous Message Sami Imseih 2026-03-02 19:09:07 Re: Fix bug in multixact Oldest*MXactId initialization and access