Warning on Linux with GCC 9.3.0 - will never be NULL [-Waddress]

I encounter the warning “will never be NULL [-Waddress]” on Ubuntu 20.04.1 with GCC 9.3.0:

.../JUCE/modules/juce_gui_basics/native/juce_linux_Windowing.cpp:782:72:   required from here
.../JUCE/modules/juce_core/misc/juce_Functional.h:57:16: warning: the address of ‘static constexpr void juce::showDialog(const juce::MessageBoxOptions&, juce::ModalComponentManager::Callback*, juce::Async)::<lambda(int)>::_FUN(int)’ will never be NULL [-Waddress]
   57 |         if (fn != nullptr)
      |             ~~~^~~~~~~~~~

Any news on this? :innocent:
BTW, it happens in Release mode. And the warning is also there with GCC 9.4.0.
Tested with Juce 6.1.6 (2f98020)

I’m not able to reproduce the issue with GCC 9.4 on Ubuntu 21.10. Are you using Projucer or CMake? Are you adding any custom compilation options when configuring your project?

I use CMake with no extra compilation options but:

target_link_libraries(MySuperTarget PRIVATE
juce::juce_gui_extra
juce::juce_audio_formats
juce::juce_audio_devices
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)

but I’m on Ubuntu 20.04. I can try on 21.10.

After a few more tests, the problem seems related to the C++ standards:

set_target_properties(MySuperTarget PROPERTIES CXX_STANDARD 20)

I tried directly with a JUCE example (GuiAppExample) - you can also use CMAKE_CXX_STANDARD 20.

Using an older C++ standard fix the issue. I tried on Ubuntu 21.10 and it also happens with GCC 9.4 but not with more recent versions. Do you think it’s a bug of this GCC version with C++20?

Thanks for reporting. The issue should be fixed here:

1 Like