Warning -Wmaybe-uninitialized in normal.c at 9.1.1863 (and possibly shortly before it)

17 views
Skip to first unread message

Tony Mechelynck

unread,
Oct 16, 2025, 4:48:18 PM (5 days ago) Oct 16
to Christian Brabandt, vim_dev
This happens in Normal and Huge builds, not in Tiny. Also in Normal
with Motif GUI but not in Tiny with Motif GUI:

normal.c: In function ‘normal_cmd’:
normal.c:991:19: warning: ‘prev_VIsual_active’ may be used
uninitialized [-Wmaybe-uninitialized]
991 | if (finish_op || prev_VIsual_active)
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
normal.c:972:9: note: ‘prev_VIsual_active’ was declared here
972 | int prev_VIsual_active = VIsual_active;
| ^~~~~~~~~~~~~~~~~~

I think it's over-cautiousness on the part of gcc (SUSE Linux) 15.2.1
20251006. It may look silly, but what about replacing line 972 by the
following?

/* avoid gcc warning -Wmaybe-uninitialized a little lower */
int prev_Visual_active = 0;
prev_Visual_active = Visual_active;

Best regards,
Tony.

Christian Brabandt

unread,
Oct 17, 2025, 2:00:33 PM (4 days ago) Oct 17
to Tony Mechelynck, vim_dev
I don't understand how this can happen and the warning already shows
that prev_VIsual_active has been initialized, so not sure.

Well, I installed gcc-15 on my Debian box, but it doesn't complain.

Thanks,
Christian
--
Romeo wasn't bilked in a day.
-- Walt Kelly, "Ten Ever-Lovin' Blue-Eyed Years With Pogo"

John

unread,
Oct 18, 2025, 7:31:12 AM (3 days ago) Oct 18
to vim...@googlegroups.com
Perhaps the warning comes about because the various goto statements (at
lines 831, 836, 861 and 920) will take us to line 986 which is below the
initialisation of prev_VIsual_active at line 972.

Just a thought.

Cheers
John




Christian Brabandt

unread,
Oct 18, 2025, 9:27:55 AM (3 days ago) Oct 18
to vim...@googlegroups.com

On Sa, 18 Okt 2025, John wrote:

> On 18-Oct-2025 05:00, Christian Brabandt wrote:
> > On Do, 16 Okt 2025, Tony Mechelynck wrote:
> >
> > > This happens in Normal and Huge builds, not in Tiny. Also in Normal
> > > with Motif GUI but not in Tiny with Motif GUI:
> > >
> > > normal.c: In function ‘normal_cmd’:
> > > normal.c:991:19: warning: ‘prev_VIsual_active’ may be used
> > > uninitialized [-Wmaybe-uninitialized]
> > > 991 | if (finish_op || prev_VIsual_active)
> > > | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
> > > normal.c:972:9: note: ‘prev_VIsual_active’ was declared here
> > > 972 | int prev_VIsual_active = VIsual_active;
> > > | ^~~~~~~~~~~~~~~~~~
> > >
> > > I think it's over-cautiousness on the part of gcc (SUSE Linux) 15.2.1
> > > 20251006. It may look silly, but what about replacing line 972 by the
> > > following?
> > >
> > > /* avoid gcc warning -Wmaybe-uninitialized a little lower */
> > > int prev_Visual_active = 0;
> > > prev_Visual_active = Visual_active;
> > I don't understand how this can happen and the warning already shows
> > that prev_VIsual_active has been initialized, so not sure.
> >
> > Well, I installed gcc-15 on my Debian box, but it doesn't complain.

> Perhaps the warning comes about because the various goto statements (at
> lines 831, 836, 861 and 920) will take us to line 986 which is below the
> initialisation of prev_VIsual_active at line 972.

Ah yes, possible. Let's see if https://github.com/vim/vim/pull/18597
fixes this warning.

Thanks,
Christian
--
I'm ANN LANDERS!! I can SHOPLIFT!!

Christian Brabandt

unread,
Oct 18, 2025, 10:41:16 AM (3 days ago) Oct 18
to vim...@googlegroups.com

On Sa, 18 Okt 2025, Christian Brabandt wrote:

> Ah yes, possible. Let's see if https://github.com/vim/vim/pull/18597
> fixes this warning.

So I merged it in. The warning should be fixed now with v9.1.1868

Thanks,
Christian
--
Some of us are becoming the men we wanted to marry.
-- Gloria Steinem
Reply all
Reply to author
Forward
0 new messages