Search

Compiler Error C2382 with Standard Header File <system_error> in Visual C++ 2012 RC by sunseraphic

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 745967
Opened: 6/1/2012 11:54:52 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Hi,

I am try to compile Clang on my windows 7 workstation with Visual C++ 11 in Visual Studio 2012 RC.

I met a error C2382 with standard header file system_error, so I investigate its source code and found:

// Line 155
const error_category& generic_category();
const error_category& iostream_category();
const error_category& system_category();

// Line
inline const error_category& generic_category() _NOEXCEPT
    {    // get generic_category
    return (_Error_objects<int>::_Generic_object);
    }

inline const error_category& iostream_category() _NOEXCEPT
    {    // get iostream_category
    return (_Error_objects<int>::_Iostream_object);
    }

inline const error_category& system_category() _NOEXCEPT
    {    // get system_category
    return (_Error_objects<int>::_System_object);
    }

where macro "_NOEXCEPT" was defined in yvals.h

// Line 18
#define _NOEXCEPT    throw ()

As it cames from Clang's clangCodeGen project, I inspected this project setting, and found that /Za option is ON!

That's said this case may be ignored with default configuration of VC++ 2012 RC, but when you turn /Za option on, it would came out!

All above, hope you can fix this in RTM.

By the way, according to C++11 Standard, these function sould be defined like this:

ISO/IEC 14882:2011(E)
19.5.1 Class error_category [syserr.errcat]
19.5.1.1 Class error_category overview [syserr.errcat.overview]

const error_category& generic_category() noexcept;
const error_category& system_category() noexcept;

I don't know why VC++ did not support C++11 keyword "noexcept", but if you dont like introducing new keyword, I suggest that you may support a combined keyword with existed keyword, such as:

"do not throw while using this"

instead.

Just for fun : ), this joke is from here:
http://lists.boost.org/Archives/boost/2009/07/154074.php
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

Visual Studio 2012 RC

Steps to reproduce

1. Write a correct Hello World cpp
2. include <system_error> at the beginnning of the source above
3. turn on /Za option for your project
4. compile this source file

Product Language

Chinese - Simplified

Operating System

Windows 7

Operating System Language

Chinese (Simplified)

Actual results

When /Za option is On, any source code include <system_error> would met compile error C2382.

Expected results

Whether or not /Za option is On, any source code include <system_error> should not met such an error with the standard functions.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 6/5/2012 at 11:12 PM
Hi,

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

Please note that /Za is buggy and breaks conformant code, such as vector<unique_ptr<T>>. As a result, we recommend against using /Za, and we stopped testing the STL with it during VC10's development.

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 MS-Moderator01 on 6/2/2012 at 12:42 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.