compiler bug -- mistaken C3821 when invoking new in ctor-initializer-list (regression)

  • Thread starter Thread starter Ben Voigt [C++ MVP]
  • Start date Start date
Ben said:
Please validate this bug:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=473352

Here is the test case:

#pragma managed(push, off)
#include <list>

class C3821
{
std::list<int*>* p;

public:
C3821( size_t n )
: p(new std::list<int*>[n])
{
}
};
#pragma managed(pop)

I've been able to verify that it works in VS2005 SP1 but not in VS2008 SP1,
appreciate anyone who can check it on RTM versions or has VS2010 beta handy.
VS 2010 output:

1>ClCompile:
1> c3821.cpp
1>c3821.cpp(9): error C2711: 'C3821::C3821' : this functon cannot be
compiled as managed, consider using #pragma unmanaged
1> #pragma unmanaged is in effect
1> c3821.cpp(11) : see source of the previous compiler diagnostic
1>c3821.cpp(12): error C3821: 'C3821::C3821(size_t)': managed type or
function cannot be used in an unmanaged function

So you have to use #pragma unmanaged, which also happens to be in effect, so
the error is obvious, right? (And yes, this is verbatim output, it's
"functon" -- well, it's a beta.)
 
Jeroen said:
Ben said:
Please validate this bug:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=473352

Here is the test case:

#pragma managed(push, off)
#include <list>

class C3821
{
std::list<int*>* p;

public:
C3821( size_t n )
: p(new std::list<int*>[n])
{
}
};
#pragma managed(pop)

I've been able to verify that it works in VS2005 SP1 but not in
VS2008 SP1, appreciate anyone who can check it on RTM versions or
has VS2010 beta handy.
VS 2010 output:

1>ClCompile:
1> c3821.cpp
1>c3821.cpp(9): error C2711: 'C3821::C3821' : this functon cannot be
compiled as managed, consider using #pragma unmanaged
1> #pragma unmanaged is in effect
1> c3821.cpp(11) : see source of the previous compiler
diagnostic 1>c3821.cpp(12): error C3821: 'C3821::C3821(size_t)':
managed type or function cannot be used in an unmanaged function

So you have to use #pragma unmanaged, which also happens to be in
effect, so the error is obvious, right? (And yes, this is verbatim
output, it's "functon" -- well, it's a beta.)

Beta status is no excuse when that identical error message and (mis)spelling
is produced by the VS2008 SP1 compiler ;)

C2711 is confusing because unmanaged mode is selected. But I think it is
produced as a side effect of the C3821. It's trying to recover from C3821
by compiling the code to MSIL instead of native, and my pragma forbids that,
hence the C2711.

The issue is C3821. There is no use of any managed type, and the error
message makes no attempt to explain which type or function the compiler
thought was being used.
 
Hello Ben

I looked up the issue in the product database. The issue is active in the
Visual Studio 2010 issue DB. The product group is aware of it and is in
progress of researching it. I will convey your comments above to the team.

Regards,
Jialiang Ge
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
"Jialiang Ge [MSFT]" said:
Hello Ben

I looked up the issue in the product database. The issue is active in the
Visual Studio 2010 issue DB. The product group is aware of it and is in
progress of researching it. I will convey your comments above to the team.

Thanks. I just wish I had encountered this before the VS2010 bug bar got
raised, now it probably can't be fixed until VS.next.
Regards,
Jialiang Ge
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no
rights.
=================================================


__________ Information from ESET NOD32 Antivirus, version of virus
signature database 4236 (20090712) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4236 (20090712) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
Back
Top