Closed Bug 1261719 Opened 8 years ago Closed 8 years ago

"mozalloc.h: 'operator new': non-member operator new or delete functions may not be declared inline" error with WAE and VisualStudio 2015 Update 2

Categories

(Core :: General, defect)

Unspecified
Windows
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla48
Tracking Status
firefox48 --- fixed

People

(Reporter: cpearce, Unassigned)

References

Details

Attachments

(1 file)

I get a build failure with Warnings As Errors enabled with VisualStudio 2015 Pro Update 2:

 1:53.47 In the directory  /c/Users/cpearce/src/central/objdir/dom/cellbroadcast
 1:53.47 The following command failed to execute properly:
 1:53.47 c:/Users/cpearce/src/central/objdir/_virtualenv/Scripts/python.exe -m mozbuild.action.cl cl -FoUnified_cpp_dom_cellbroadcast0.obj -c -Ic:/Users/cpearce/src/central/objdir/dist/stl_wrappers -DDEBUG=1 -DTRACING=1 -DWIN32_LEAN_AND_MEAN -D_WIN32 -DWIN32 -D_CRT_RAND_S -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DOS_WIN=1 -D_UNICODE -DCHROMIUM_BUILD -DU_STATIC_IMPLEMENTATION -DUNICODE -D_WINDOWS -D_SECURE_ATL -DCOMPILER_MSVC -DSTATIC_EXPORTABLE_JS_API -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -Ic:/Users/cpearce/src/central/dom/cellbroadcast -Ic:/Users/cpearce/src/central/objdir/dom/cellbroadcast -Ic:/Users/cpearce/src/central/objdir/ipc/ipdl/_ipdlheaders -Ic:/Users/cpearce/src/central/ipc/chromium/src -Ic:/Users/cpearce/src/central/ipc/glue -Ic:/Users/cpearce/src/central/objdir/dist/include -Ic:/Users/cpearce/src/central/objdir/dist/include/nspr -Ic:/Users/cpearce/src/central/objdir/dist/include/nss -MD -FI c:/Users/cpearce/src/central/objdir/mozilla-config.h -DMOZILLA_CLIENT -TP -nologo -wd5026 -wd5027 -Zc:sizedDealloc- -Zc:threadSafeInit- -wd4091 -D_HAS_EXCEPTIONS=0 -W3 -Gy -arch:IA32 -FS -wd4251 -wd4244 -wd4267 -wd4345 -wd4351 -wd4800 -wd4819 -we4553 -GR- -Zi -O1 -Oi -Oy- -WX -Fdgenerated.pdb c:/Users/cpearce/src/central/objdir/dom/cellbroadcast/Unified_cpp_dom_cellbroadcast0.cpp
 1:53.47 c:/Users/cpearce/src/central/config/rules.mk:918: recipe for target 'Unified_cpp_dom_cellbroadcast0.obj' failed
 1:53.47 mozmake.EXE[5]: *** [Unified_cpp_dom_cellbroadcast0.obj] Error 1
 1:53.47 c:/Users/cpearce/src/central/config/recurse.mk:71: recipe for target 'dom/cellbroadcast/target' failed
 1:53.47 mozmake.EXE[4]: *** [dom/cellbroadcast/target] Error 2
 1:56.27 Unified_cpp_dom_presentation0.cpp
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(184): error C2220: warning treated as error - no 'object' file generated
 1:56.27 Warning: C4595 in c:\users\cpearce\src\central\objdir\dist\include\mozilla\mozalloc.h: 'operator new': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(184): warning C4595: 'operator new': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(184): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
 1:56.27 Warning: C4595 in c:\users\cpearce\src\central\objdir\dist\include\mozilla\mozalloc.h: 'operator new': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(190): warning C4595: 'operator new': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(190): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
 1:56.27 Warning: C4595 in c:\users\cpearce\src\central\objdir\dist\include\mozilla\mozalloc.h: 'operator new[]': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(196): warning C4595: 'operator new[]': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(196): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
 1:56.27 Warning: C4595 in c:\users\cpearce\src\central\objdir\dist\include\mozilla\mozalloc.h: 'operator new[]': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(202): warning C4595: 'operator new[]': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(202): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
 1:56.27 Warning: C4595 in c:\users\cpearce\src\central\objdir\dist\include\mozilla\mozalloc.h: 'operator delete': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(208): warning C4595: 'operator delete': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(208): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
 1:56.27 Warning: C4595 in c:\users\cpearce\src\central\objdir\dist\include\mozilla\mozalloc.h: 'operator delete': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(214): warning C4595: 'operator delete': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(214): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
 1:56.27 Warning: C4595 in c:\users\cpearce\src\central\objdir\dist\include\mozilla\mozalloc.h: 'operator delete[]': non-member operator new or delete functions may not be declared inline
 1:56.27 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(220): warning C4595: 'operator delete[]': non-member operator new or delete functions may not be declared inline
 1:56.28 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(220): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
 1:56.28 Warning: C4595 in c:\users\cpearce\src\central\objdir\dist\include\mozilla\mozalloc.h: 'operator delete[]': non-member operator new or delete functions may not be declared inline
 1:56.28 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(226): warning C4595: 'operator delete[]': non-member operator new or delete functions may not be declared inline
 1:56.28 c:\users\cpearce\src\central\objdir\dist\include\mozilla/mozalloc.h(226): note: to simplify migration, consider the temporary use of /Wv:18 flag with the version of the compiler with which you used to build without warnings
 1:56.28
 1:56.28 In the directory  /c/Users/cpearce/src/central/objdir/dom/presentation
 1:56.28 The following command failed to execute properly:
 1:56.28 c:/Users/cpearce/src/central/objdir/_virtualenv/Scripts/python.exe -m mozbuild.action.cl cl -FoUnified_cpp_dom_presentation0.obj -c -Ic:/Users/cpearce/src/central/objdir/dist/stl_wrappers -DDEBUG=1 -DTRACING=1 -DWIN32_LEAN_AND_MEAN -D_WIN32 -DWIN32 -D_CRT_RAND_S -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DOS_WIN=1 -D_UNICODE -DCHROMIUM_BUILD -DU_STATIC_IMPLEMENTATION -DUNICODE -D_WINDOWS -D_SECURE_ATL -DCOMPILER_MSVC -DSTATIC_EXPORTABLE_JS_API -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -Ic:/Users/cpearce/src/central/dom/presentation -Ic:/Users/cpearce/src/central/objdir/dom/presentation -Ic:/Users/cpearce/src/central/objdir/ipc/ipdl/_ipdlheaders -Ic:/Users/cpearce/src/central/ipc/chromium/src -Ic:/Users/cpearce/src/central/ipc/glue -Ic:/Users/cpearce/src/central/objdir/dist/include -Ic:/Users/cpearce/src/central/objdir/dist/include/nspr -Ic:/Users/cpearce/src/central/objdir/dist/include/nss -MD -FI c:/Users/cpearce/src/central/objdir/mozilla-config.h -DMOZILLA_CLIENT -TP -nologo -wd5026 -wd5027 -Zc:sizedDealloc- -Zc:threadSafeInit- -wd4091 -D_HAS_EXCEPTIONS=0 -W3 -Gy -arch:IA32 -FS -wd4251 -wd4244 -wd4267 -wd4345 -wd4351 -wd4800 -wd4819 -we4553 -GR- -Zi -O1 -Oi -Oy- -WX -Fdgenerated.pdb c:/Users/cpearce/src/central/objdir/dom/presentation/Unified_cpp_dom_presentation0.cpp
 1:56.29 c:/Users/cpearce/src/central/config/rules.mk:918: recipe for target 'Unified_cpp_dom_presentation0.obj' failed
 1:56.29 mozmake.EXE[5]: *** [Unified_cpp_dom_presentation0.obj] Error 1
 1:56.29 c:/Users/cpearce/src/central/config/recurse.mk:71: recipe for target 'dom/presentation/target' failed
 1:56.29 mozmake.EXE[4]: *** [dom/presentation/target] Error 2
 1:56.29 c:/Users/cpearce/src/central/config/recurse.mk:32: recipe for target 'compile' failed
 1:56.29 mozmake.EXE[3]: *** [compile] Error 2
 1:56.29 c:/Users/cpearce/src/central/config/rules.mk:531: recipe for target 'default' failed
 1:56.29 mozmake.EXE[2]: *** [default] Error 2
 1:56.29 c:/Users/cpearce/src/central/client.mk:419: recipe for target 'realbuild' failed
 1:56.29 mozmake.EXE[1]: *** [realbuild] Error 2
 1:56.29 client.mk:181: recipe for target 'build' failed
 1:56.29 mozmake.EXE: *** [build] Error 2
 1:56.32 33 compiler warnings present.
2


The warning being promoted to an error there is:

\mozilla/mozalloc.h(226): warning C4595: 'operator delete[]': non-member operator new or delete functions may not be declared inline

This warning was suppressed for newer clang versions in bug 928808.
C4595 is "'operator new': non-member operator new or delete functions may not be declared inline".
This warning is already suppressed for newer versions of clang.

Review commit: https://reviewboard.mozilla.org/r/44057/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/44057/
Attachment #8737652 - Flags: review?(mh+mozilla)
I went looking for an explanation of this warning.  According to https://msdn.microsoft.com/en-us/library/mt656697.aspx:

"Previous versions of the compiler do not issue a warning when non-member operator new and operator delete functions are declared inline. Code written in this way is ill-formed (no diagnostic required) and can cause memory issues resulting from mismatched new and delete operators (especially when used together with sized deallocation) that can be difficult to diagnose. The compiler now issues compiler warning C4595 to help identify code written in this way."

IANALL, but they believe non-member operator new/delete shouldn't be inlined...
Comment on attachment 8737652 [details]
MozReview Request: Bug 1261719 - Suppress MSVC warning C4595. r?glandium

https://reviewboard.mozilla.org/r/44057/#review41147
Attachment #8737652 - Flags: review?(mh+mozilla) → review+
https://hg.mozilla.org/mozilla-central/rev/542411a64ac4
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
Blocks: 1266809
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: