Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

conflict with new[] using Intel Compiler vs. MS compiler

zuikway
Beginner
954 Views
I'm wondering if anyone can help me with the following problem using
the Intel compiler (C++ 7.0) in the VS .NET environment and operator
new multiple definitions.

I converted a C++ VS 6 program over to VS .NET and everything compiled
just fine using the MS compiler. Then I installed the Intel C++ 7.0
compiler and tried to compile. (using Debug target) I got the following
error message:

-----------------------intel compiler error message----------------------
C:Program FilesMicrosoft Visual Studio .NETVc7include ew(84):
error: exception specification is incompatible with that of previous function
"operator new[](size_t={unsigned int})" (declared at line 645 of
"C:Program FilesMicrosoft Visual Studio .NETVc7includecrtdbg.h")
_THROW1(std::bad_alloc); // allocate array or throw exception

or after commenting out the definition in crtdbg.h I get:

C:Program FilesMicrosoft Visual Studio .NETVc7include ew(84):
error: exception specification is incompatible with that of previous function
"operator new[](size_t={unsigned int})" (declared at line 1315 of
"C:Program FilesMicrosoft Visual Studio .NETVc7atlmfcincludeafx.h")
_THROW1(std::bad_alloc); // allocate array or throw exception
^
------------------------------------------------------------------------

The problem seems to be the definition of operator new[] in the file
"crtdbg.h" or "afx.h" versus in the file "new". Both are MS.NET files.
"crtdbg.h" has:

extern "C++" {
void * __cdecl operator new[](size_t);
}

and the conflicting definition of operator new[] in the file "new":

void *__cdecl operator new[](size_t)
_THROW1(std::bad_alloc); // allocate array or throw exception

Not sure if this is a MS issue or Intel issue. I compiled with just the
preprocessor output to see if there were any differences between the
two compilers, but it appears both produce the same preprocessed
output. The MS compiler does not seem to complain while the intel
compiler does. I thought maybe it had something to do with namespaces.
File "new" does not define the operator new[] in std:: namespace. There
is also a definition of new[] in afx.h, such that if I comment out the
one in crtdbg.h, then it conflicts with the definintion in afx.h.

Any suggestions? I'd hate to have to starting modifying MS files just
to use the intel compiler.

Wayne
0 Kudos
3 Replies
zuikway
Beginner
954 Views
After installing the latest intel compiler and .NET service pack, I no longer have this problem.

Wayne
0 Kudos
maxheadroom
Beginner
957 Views
could you please post the version numbers which fixed your problem as we run into the same troubles here.

our installed versions are:
winXP pro
VS.NET 2002 7.0.9514
.NET Framework 1.0 SP2
Intel c++ 7.0.073 30 day evaluation

is there a newer version of the compiler ?
access to the premier support pages fail (although
we registered our version) with a
"webpage forbidden" error.
0 Kudos
zuikway
Beginner
957 Views
.NET Framework SP2 and latest intel compiler:
version 7.0.085 latest beta release off
the premier web site https://premier.intel.com/
Not sure that this is available off the regular
evaluation download, but you could check.

Wayne
0 Kudos
Reply