Windows ClangCL build warnings in 8.0.3

Hi I’m getting a bunch of repeating warnings when I compile with Clang:
It’s to do with the first line of function readDoubleValue.

   static double readDoubleValue (CharPointerType& text) noexcept
    {
        constexpr auto inf = std::numeric_limits<double>::infinity();
 . . .
14:35:34:996	4>D:\Plug-ins\JUCE\modules\juce_core\text/juce_CharacterFunctions.h(225,30): warning : use of infinity is undefined behavior due to the currently enabled floating-point options [-Wnan-infinity-disabled]
14:35:34:996	4>D:\Plug-ins\JUCE\modules\juce_core\text/juce_CharacterFunctions.h(423,16): message : in instantiation of function template specialization 'juce::CharacterFunctions::readDoubleValue<juce::CharPointer_UTF16>' requested here
14:35:34:996	4>D:\Plug-ins\JUCE\modules\juce_core\text/juce_CharPointer_UTF16.h(430,94): message : in instantiation of function template specialization 'juce::CharacterFunctions::getDoubleValue<juce::CharPointer_UTF16>' requested here
14:35:34:996	4>In file included from ..\..\JuceLibraryCode\include_juce_audio_plugin_client_VST3.cpp:9:
14:35:34:996	4>In file included from D:\Plug-ins\JUCE\modules\juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp:58:
14:35:34:996	4>In file included from D:\Plug-ins\JUCE\modules\juce_audio_plugin_client/detail/juce_PluginUtilities.h:37:
14:35:34:996	4>In file included from D:\Plug-ins\JUCE\modules\juce_audio_plugin_client/detail/juce_IncludeModuleHeaders.h:37:
14:35:34:996	4>In file included from D:\Plug-ins\JUCE\modules\juce_audio_plugin_client/juce_audio_plugin_client.h:63:
14:35:34:996	4>In file included from D:\Plug-ins\JUCE\modules\juce_gui_basics/juce_gui_basics.h:68:
14:35:34:996	4>In file included from D:\Plug-ins\JUCE\modules\juce_graphics/juce_graphics.h:67:
14:35:34:996	4>In file included from D:\Plug-ins\JUCE\modules\juce_core/juce_core.h:243:
14:35:34:996	4>D:\Plug-ins\JUCE\modules\juce_core\text/juce_CharacterFunctions.h(225,30): warning : use of infinity is undefined behavior due to the currently enabled floating-point options [-Wnan-infinity-disabled]
14:35:34:996	4>D:\Plug-ins\JUCE\modules\juce_core\text/juce_CharacterFunctions.h(423,16): message : in instantiation of function template specialization 'juce::CharacterFunctions::readDoubleValue<juce::CharPointer_UTF32>' requested here
14:35:34:996	4>D:\Plug-ins\JUCE\modules\juce_core\text/juce_CharPointer_UTF32.h(349,78): message : in instantiation of function template specialization 'juce::CharacterFunctions::getDoubleValue<juce::CharPointer_UTF32>' requested here
14:35:34:996	4>In file included from ..\..\JuceLibraryCode\include_juce_audio_plugin_client_VST3.cpp:9:
  • Which version of clang are you using?
  • On which platform?
  • What is the full set of custom compiler flags you are using, if any?

I guess you’re setting -ffast-math or similar, but we don’t test JUCE with this flag enabled. If you’re currently applying this flag to every file in the project, perhaps you could consider applying only to performance-critical translation units instead.

Sorry, it says in the title ‘Windows’ and I’ve posted this on the Windows forum.
Visual Studio 2022.
I have no idea what Clang I’m using, it just has the option ClangCL in Projucer

Yes, I’m using -ffast-math. I didn’t have the warning in Juce 7, so I guess juce_CharacterFunctions.h is new.

Whoops, my reading comprehension seems to have suffered a bit post-ADC!

Do you know whether you’ve updated clang recently? That warning was only introduced in clang 18.1.6 (released in May), so that’s probably the cause of the new warning. I think this would still have caused issues in older versions of the compiler, though.

Maybe you could work around this by removing the -ffast-math flag for all source files, and instead applying it on a per-file basis to files that really need this flag.

1 Like

Thanks for looking into it, reuk.

The warning only occurs in juce_CharacterFunctions.h
which uses
constexpr auto inf = std::numeric_limits::infinity();

How do I remove or add ffast-math flag from source files? I’m using projucer to build my plugs.

ffast-math is useful for all the graphics stuff, like Fonts drawing etc.
The projucer has the Relax IEEE Compliance option, shouldn’t Juce be tested with that option Enabled?

OK - After much searching, I put

// top...
#pragma float_control( precise, on, push) 
. . .
. . . 
// Bottom...
#pragma float_control(pop)

Around the juce_CharacterFunctions.h file. It seems to do the trick for me.

1 Like