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

GCC11 complains a lot about -Wmismatched-new-delete #8900

Closed
Milek7 opened this issue Mar 27, 2021 · 3 comments
Closed

GCC11 complains a lot about -Wmismatched-new-delete #8900

Milek7 opened this issue Mar 27, 2021 · 3 comments
Labels
priority: low

Comments

@Milek7
Copy link
Contributor

Milek7 commented Mar 27, 2021

Coming GCC 11 introduced new warning, -Wmismatched-new-delete.
It complains a lot in OpenTTD code: (this is short excerpt, there's a lot more similiar warnings)

/home/milek7/ottd2/src/ai/ai_gui.cpp: In function ‘void ShowAIListWindow(CompanyID)’:
/home/milek7/ottd2/src/ai/ai_gui.cpp:280:46: warning: ‘static void Window::operator delete(void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
  280 |         new AIListWindow(&_ai_list_desc, slot);
      |                                              ^
/home/milek7/ottd2/src/ai/ai_gui.cpp:280:46: note: returned from ‘static void* ZeroedMemoryAllocator::operator new(size_t)’
[ 58%] Building CXX object CMakeFiles/openttd.dir/src/blitter/40bpp_anim.cpp.o
/home/milek7/ottd2/src/ai/ai_gui.cpp: In function ‘void ShowAISettingsWindow(CompanyID)’:
/home/milek7/ottd2/src/ai/ai_gui.cpp:633:54: warning: ‘static void Window::operator delete(void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
  633 |         new AISettingsWindow(&_ai_settings_desc, slot);
      |                                                      ^
/home/milek7/ottd2/src/ai/ai_gui.cpp:633:54: note: returned from ‘static void* ZeroedMemoryAllocator::operator new(size_t)’
/home/milek7/ottd2/src/ai/ai_gui.cpp: In function ‘void ShowScriptTextfileWindow(TextfileType, CompanyID)’:
/home/milek7/ottd2/src/ai/ai_gui.cpp:673:49: warning: ‘static void Window::operator delete(void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
  673 |         new ScriptTextfileWindow(file_type, slot);
      |                                                 ^
/home/milek7/ottd2/src/ai/ai_gui.cpp:673:49: note: returned from ‘static void* ZeroedMemoryAllocator::operator new(size_t)’
/home/milek7/ottd2/src/ai/ai_gui.cpp: In function ‘void ShowAIConfigWindow()’:
/home/milek7/ottd2/src/ai/ai_gui.cpp:974:28: warning: ‘static void Window::operator delete(void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
  974 |         new AIConfigWindow();
      |                            ^
/home/milek7/ottd2/src/ai/ai_gui.cpp:974:28: note: returned from ‘static void* ZeroedMemoryAllocator::operator new(size_t)’
/home/milek7/ottd2/src/ai/ai_gui.cpp: In function ‘Window* ShowAIDebugWindow(CompanyID)’:
/home/milek7/ottd2/src/ai/ai_gui.cpp:1539:75: warning: ‘static void Window::operator delete(void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
 1539 |                 if (w == nullptr) w = new AIDebugWindow(&_ai_debug_desc, 0);
      |                                                                           ^
/home/milek7/ottd2/src/ai/ai_gui.cpp:1539:75: note: returned from ‘static void* ZeroedMemoryAllocator::operator new(size_t)’
@LordAro
Copy link
Member

LordAro commented Mar 28, 2021

JGR fix here: JGRennison/OpenTTD-patches@6573a67

@TrueBrain TrueBrain added the priority: low label Apr 10, 2021
@LordAro
Copy link
Member

LordAro commented Jul 19, 2021

Is this still a thing? I'm getting no warnings with GCC11.1 (I've explicitly set the warning with cmake -DCMAKE_CXX_FLAGS="-Wmismatched-new-delete")

@Milek7
Copy link
Contributor Author

Milek7 commented Jul 19, 2021

It was fixed by #9227

@Milek7 Milek7 closed this as completed Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low
Projects
None yet
Development

No branches or pull requests

3 participants