Warning [maybe-uninitialized] building juce_gui_basics

With develop branch on Ubuntu 20.04 i get a warning building JUCE.

Compiler is gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1).

Compiling Main.cpp
Compiling BinaryData.cpp
Compiling include_juce_core.cpp
Compiling include_juce_data_structures.cpp
Compiling include_juce_events.cpp
Compiling include_juce_graphics.cpp
Compiling include_juce_gui_basics.cpp
In file included from /home/jojo/JUCE/modules/juce_gui_basics/juce_gui_basics.cpp:332,
                 from ../../JuceLibraryCode/include_juce_gui_basics.cpp:8:
/home/jojo/JUCE/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp: In member function ‘juce::Array<juce::Displays::Display> juce::XWindowSystem::findDisplays(float) const’:
/home/jojo/JUCE/modules/juce_gui_basics/native/x11/juce_linux_XWindowSystem.cpp:2581:53: warning: ‘<anonymous>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 2581 |                                             return {};
      |                                                     ^
Compiling include_spaghettis_core.cpp
Compiling include_spaghettis_gui.cpp
Linking Spaghettis - App

Looking at the site generating the warning this appears to be a GCC bug.

Also testing on a couple systems (Ubuntu 20 and 22 with GCC 9.4.0) we couldn’t reproduce this warning on our machines.

maybe-uninitialized seems to be generally not reliable enough to leave it enabled and instead litter the codebase with local warning disabling pragmas. This is the reason why no-maybe-uninitialized is part of juce_recommended_warning_flags

That being the case I can only recommend that you consider disabling the warning either by using the JUCE recommended flags or setting no-maybe-uninitialised globally.

1 Like

The -Wno-maybe-uninitialized flag is not recognized by clang on my RPI4. :unamused: