Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation warning -Wstringop-overflow= in audio_effect_pitch_shift.cpp with mingw-gcc #101236

Open
threezinedine opened this issue Jan 7, 2025 · 3 comments · May be fixed by #101279
Open

Compilation warning -Wstringop-overflow= in audio_effect_pitch_shift.cpp with mingw-gcc #101236

threezinedine opened this issue Jan 7, 2025 · 3 comments · May be fixed by #101279

Comments

@threezinedine
Copy link

Tested versions

System information

Windows 11 - MinGW

Issue description

I encountered a compilation error when building the Godot Engine from source using scons on Windows with the mingw compiler. The error occurs in audio_effect_pitch_shift.cpp, specifically due to a memset operation that exceeds the maximum object size.

Steps to reproduce

Clone the Godot Engine source code repository.

Run the following command to compile:

scons platform=windows use_mingw=yes dev_mode=yes

Observed Output:

The compilation fails with the following error:

ERROR: servers\audio\effects\audio_effect_pitch_shift.cpp: In member function 'void SMBPitchShift::PitchShift(float, long int, long int, long int, float, float*, float*, int)':
servers\audio\effects\audio_effect_pitch_shift.cpp:163:31: error: 'void* memset(void*, int, size_t)' specified bound between 18446744065119617024 and 18446744073709551608 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
  163 |                         memset(gSynMagn, 0, fftFrameSize*sizeof(float));
      |                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
servers\audio\effects\audio_effect_pitch_shift.cpp:164:31: error: 'void* memset(void*, int, size_t)' specified bound between 18446744065119617024 and 18446744073709551608 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
  164 |                         memset(gSynFreq, 0, fftFrameSize*sizeof(float));
      |                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus.exe: all warnings being treated as errors

System Information:

OS: Windows 11

Compiler: MinGW

Please let me know if further information or logs are needed to assist in diagnosing this problem.

Minimal reproduction project (MRP)

N/A

@akien-mga akien-mga changed the title Compilation Error in audio_effect_pitch_shift.cpp When Using scons Compilation warning -Wstringop-overflow= in audio_effect_pitch_shift.cpp with mingw-gcc Jan 7, 2025
@akien-mga
Copy link
Member

Note that this is only a warning, but it's treated as error because dev_mode=yes enables werror=yes, i.e. treating warnings as errors.

I've actually reported this a while ago in #88504 already, and attempted to fix it twice with #88509 and then #88658, but it's elusive and seems to keep coming back...

@akien-mga
Copy link
Member

Could you test if this fixes the warning?

diff --git a/servers/audio/effects/audio_effect_pitch_shift.h b/servers/audio/effects/audio_effect_pitch_shift.h
index 949ce96057..381833c24a 100644
--- a/servers/audio/effects/audio_effect_pitch_shift.h
+++ b/servers/audio/effects/audio_effect_pitch_shift.h
@@ -77,7 +77,7 @@ class AudioEffectPitchShift : public AudioEffect {
 public:
 	friend class AudioEffectPitchShiftInstance;
 
-	enum FFTSize {
+	enum FFTSize : unsigned int {
 		FFT_SIZE_256,
 		FFT_SIZE_512,
 		FFT_SIZE_1024,

@threezinedine
Copy link
Author

It works, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants