Search

New warning 4986 prevents clean compile at warning level 4 by GregM

Closed
as Fixed Help for as Fixed

4
0
Sign in
to vote
Type: Bug
ID: 506966
Opened: 10/30/2009 8:40:23 PM
Access Restriction: Public
1
Workaround(s)
1
User(s) can reproduce this bug
Source that compiles cleanly at warning level 4 in Visual Studio 2008 doesn't compile cleanly in VS2010 due to an inconsistency in the system headers.

vc\include\crtdbg.h(1078): warning C4986: 'operator new[]': exception specification does not match previous declaration
vc\include\new(79) : see declaration of 'operator new[]'
vc\include\crtdbg.h(1095): warning C4986: 'operator delete[]': exception specification does not match previous declaration
vc\include\new(77) : see declaration of 'operator delete[]'
Details (expand)

Product Language

English

Version

Visual Studio 2010 Beta 2

Operating System

Windows 7

Operating System Language

English

Steps to Reproduce

Include <crtdbg.h> and <new> in an empty C++ project at warning level 4, warnings as errors.

Actual Results

Compile fails.

Expected Results

Compile succeeds.
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey. [Details]

 

File Attachments
File Name Submitted By Submitted On File Size  
KCM.vcxproj (restricted) 11/4/2009 -
stdafx.cpp (restricted) 11/4/2009 -
stdafx.h (restricted) 11/4/2009 -
Sign in to post a comment.
Posted by Microsoft on 9/2/2010 at 8:49 PM
Hi,

Thanks again for reporting this bug. We've fixed it, and the fix will be available in VC11.

As always, if you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 11/5/2009 at 8:36 PM
Hi,

Thanks for reporting this issue. We've resolved it as Won't Fix for VC10, but we've marked it for consideration in a future release.

Warning 4986 is off-by-default. We test our headers extensively to verify that they compile cleanly under /W4 /analyze. (If they don't, then that's a bug.) However, we currently don't test them under /Wall (which contains a number of extremely noisy warnings that aren't intended for day-to-day use, like "function not inlined"), so they're generally not /Wall clean. We fix /Wall warnings when we can, but right now the bar for making changes to the compiler and libraries is too high for off-by-default warnings.

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 11/5/2009 at 2:18 AM
Thanks for your response. We are routing this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team
Posted by GregM on 11/4/2009 at 5:33 AM
This should be built using Debug|Win32, as that's the one I reset the intermediate and output directories. The others have these set to directories above this directory.
Posted by GregM on 11/4/2009 at 5:29 AM
I'm attaching a simple project that demonstrates it. It uses /Wall, so I'm guessing that /Wall is required here, not just /W4
Posted by Microsoft on 11/4/2009 at 12:10 AM
Hello

Thanks for your feedback. But we could not repro this issue in our lab.
Checked crtdeb.h and new.h, we found:
crtdbg.h
line 1077 #pragma warning(suppress: 4985)
line 1078 _Ret_bytecap_(_Size) void * __CRTDECL operator new[](size_t _Size);
...
line 1095 void __CRTDECL operator delete[](void *);

new.h
line 72 _Ret_opt_bytecap_(_Size) void *__CRTDECL operator new(size_t _Size, const std::nothrow_t&) throw();
line 73 _Ret_opt_bytecap_(_Size) void *__CRTDECL operator new[](size_t _Size, const std::nothrow_t&) throw();
line 74 void __CRTDECL operator delete(void *, const std::nothrow_t&) throw();
line 75 void __CRTDECL operator delete[](void *, const std::nothrow_t&) throw();
line 76 #endif

line 78 #ifndef __PLACEMENT_NEW_INLINE
line 79 #define __PLACEMENT_NEW_INLINE
line 80 inline void *__CRTDECL operator new(size_t, void *_Where)
line 81         {return (_Where); }
line 82 inline void __CRTDECL operator delete(void *, void *)
line 83        {return; }
line 84 #endif

Could you please provide us with a demo project that can be used to repro this issue? And we will re-investigate.

Thanks,
Kylin.Ming
Posted by Microsoft on 11/2/2009 at 12:39 AM
Thank you for your feedback, We are currently reviewing the issue you have submitted.

Thank you,
Visual Studio Product Team
Sign in to post a workaround.
Posted by GregM on 10/31/2009 at 7:16 AM
Add this line before the offending declarations in crtdbg.h (or add to the existing pragma)
#pragma warning(suppress: 4986)
(The help still says that suppress only works for C6xxx warnings, which is apparently no longer the case)