#include bug in v10.1 related to function objects?

#include bug in v10.1 related to function objects?

Hello,
I have the following code that compiles with g++ (4.3.2) without any warning and runs smoothly with "-ansi -pedantic -Wall". But it does not compile with Intel C++ compiler (icc, v10.1). It again worked without issues on v11. The following is the code:

#include 

using namespace std;

class Add {
	private:
		int dx;

	public: 
		Add() : dx(0) {}

		Add(int _dx) : dx(_dx) {}

		int operator() (int n)
		{
			return n+dx;
		} 

		int dee_x(int n, int tx)
		{
			return n+tx;
		}
};

int main()
{
	Add add_0;
	Add add_5(5);

	cout << add_0(100) << endl;
	cout << add_5(100) << endl;
	cout << add_0.dee_x(100,5) << endl;

	return 0;
}

The error with icc (v10.1) was:

/usr/include/c++/4.3.2/bits/char_traits.h(266): error: identifier "__builtin_memchr" is undefined
        { return static_cast(__builtin_memchr(__s, __a, __n)); }
                                               ^

/usr/include/c++/4.3.2/bits/char_traits.h(270): error: identifier "__builtin_memmove" is undefined
        { return static_cast(__builtin_memmove(__s1, __s2, __n)); }
                                         ^

/usr/include/c++/4.3.2/bits/allocator.h(143): error: identifier "__is_empty" is undefined
    template
                                     ^

/usr/include/c++/4.3.2/bits/allocator.h(143): error: function call is not allowed in a constant expression
    template
                                     ^

/usr/include/c++/4.3.2/bits/allocator.h(143): error: type name is not allowed
    template
                                                ^

/usr/include/c++/4.3.2/bits/allocator.h(160): error: identifier "__is_empty" is undefined
    template
                                     ^

/usr/include/c++/4.3.2/bits/allocator.h(160): error: function call is not allowed in a constant expression
    template
                                     ^

/usr/include/c++/4.3.2/bits/allocator.h(160): error: type name is not allowed
    template
                                                ^

/usr/include/c++/4.3.2/bits/locale_facets.tcc(1284): error: class "std::ctype_byname" is not an entity that can be instantiated
    extern template class ctype_byname;
                    ^

/usr/include/c++/4.3.2/bits/locale_facets.tcc(1319): error: class "std::ctype_byname" is not an entity that can be instantiated
    extern template class ctype_byname;
                    ^

compilation aborted for function_objects.cpp (code 2)

The same program worked with v11 without any issues. I guess there is a bug in v10.1 which seems to have been fixed. (The post is here only to report a possible bug or correct myself of some subtle mistake(s).)

TIA,
-S

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

icc 11 has better compatibility with g++ 4.3 headers than icc 10.1 did. I think you'll find that icc 10.1 didn't claim to support such recent versions of gcc. 11.1 should be out in a week or two, and it fixes some more incompatibilities with current g++.

Quoting - tim18
icc 11 has better compatibility with g++ 4.3 headers than icc 10.1 did. I think you'll find that icc 10.1 didn't claim to support such recent versions of gcc. 11.1 should be out in a week or two, and it fixes some more incompatibilities with current g++.

Thanks Tim. 11.0.083 works fine, but will upgrade to 11.1 as it arrives. :)

I'm having the same problem, but I think we only have a license for version version 10. Is there a good workaround to this problem? I've tried reverting to an earlier g++ compiler, but so far that just causes different error messages.

What can i do if my PC is cannot work with icc-11 (i not have sse2, only sse) ?

Added:
Also, i want to say that program from post #1 compile fine with 10.1 in my system (Gentoo)

Quoting - solunskiy.mitya
What can i do if my PC is cannot work with icc-11 (i not have sse2, only sse) ?

Added:
Also, i want to say that program from post #1 compile fine with 10.1 in my system (Gentoo)

icc 10.1 worked reasonably well with gcc versions up to 4.2.1, although the combination wasn't fully supported. As long as it's working for your purposes, you may as well stay with 10.1. The sse-only code option (-xK) wasn't entirely reliable (better in later 10.1 versions), so you may require the default no-sse option. The only loss would be in support of float data type vectorizable code.

Login to leave a comment.