Recently, we’ve been able to build with -W -Wall and get (almost) no warnings from JUCE, which is very nice, thank you Jules.
[EDIT: Found that enabling -O3 causes the warnings, apparently -O2 and above activate -fstrict-aliasing]
However, compiling with -O3 produces tons of warnings involving juce_Atomic.h. This is beyond my league, but googling lets me know it’s not only a cosmetic warning but may sometimes cause very serious and hard-to-debug problems.
I assume we should be able to safely compile JUCE with -O2 or -O3? I know I want to, since -march=native + -O3 gives me about 300% performance improvement on dot product vector operations (SSE).
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h: In static member function ‘static juce::int64 juce::Atomic<Type>::castTo64Bit(Type) [with Type = char*, juce::int64 = long long int]’:
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:347:141: instantiated from ‘bool juce::Atomic<Type>::compareAndSetBool(Type, Type) [with Type = char*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:281:5: instantiated from ‘Type juce::Atomic<Type>::exchange(Type) [with Type = char*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/juce_CharPointer_UTF8.h:555:102: instantiated from here
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:156:83: warning: dereferencing type-punned pointer will break strict-aliasing rules
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h: In static member function ‘static juce::int32 juce::Atomic<Type>::castTo32Bit(Type) [with Type = char*, juce::int32 = int]’:
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:347:141: instantiated from ‘bool juce::Atomic<Type>::compareAndSetBool(Type, Type) [with Type = char*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:281:5: instantiated from ‘Type juce::Atomic<Type>::exchange(Type) [with Type = char*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/juce_CharPointer_UTF8.h:555:102: instantiated from here
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:155:83: warning: dereferencing type-punned pointer will break strict-aliasing rules
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h: In static member function ‘static juce::int64 juce::Atomic<Type>::castTo64Bit(Type) [with Type = short int*, juce::int64 = long long int]’:
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:347:141: instantiated from ‘bool juce::Atomic<Type>::compareAndSetBool(Type, Type) [with Type = short int*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:281:5: instantiated from ‘Type juce::Atomic<Type>::exchange(Type) [with Type = short int*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/juce_CharPointer_UTF16.h:471:103: instantiated from here
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:156:83: warning: dereferencing type-punned pointer will break strict-aliasing rules
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h: In static member function ‘static juce::int32 juce::Atomic<Type>::castTo32Bit(Type) [with Type = short int*, juce::int32 = int]’:
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:347:141: instantiated from ‘bool juce::Atomic<Type>::compareAndSetBool(Type, Type) [with Type = short int*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:281:5: instantiated from ‘Type juce::Atomic<Type>::exchange(Type) [with Type = short int*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/juce_CharPointer_UTF16.h:471:103: instantiated from here
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:155:83: warning: dereferencing type-punned pointer will break strict-aliasing rules
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h: In static member function ‘static juce::int64 juce::Atomic<Type>::castTo64Bit(Type) [with Type = wchar_t*, juce::int64 = long long int]’:
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:347:141: instantiated from ‘bool juce::Atomic<Type>::compareAndSetBool(Type, Type) [with Type = wchar_t*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:281:5: instantiated from ‘Type juce::Atomic<Type>::exchange(Type) [with Type = wchar_t*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/juce_CharPointer_UTF32.h:367:103: instantiated from here
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:156:83: warning: dereferencing type-punned pointer will break strict-aliasing rules
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h: In static member function ‘static juce::int32 juce::Atomic<Type>::castTo32Bit(Type) [with Type = wchar_t*, juce::int32 = int]’:
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:347:141: instantiated from ‘bool juce::Atomic<Type>::compareAndSetBool(Type, Type) [with Type = wchar_t*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:281:5: instantiated from ‘Type juce::Atomic<Type>::exchange(Type) [with Type = wchar_t*]’
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/juce_CharPointer_UTF32.h:367:103: instantiated from here
../../Source/../JuceLibraryCode/modules/juce_audio_basics/../juce_core/system/../logging/../text/../memory/juce_Atomic.h:155:83: warning: dereferencing type-punned pointer will break strict-aliasing rules