LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-12-2009, 03:29 AM   #1
Sinedie
Member
 
Registered: Nov 2006
Posts: 71

Rep: Reputation: 15
Programming bug or icc bug?


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). The following is the code:

Code:
#include <iostream>

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 main()
{
        Add add_0;
        Add add_5(5);

        cout << add_0(100) << endl;
        cout << add_5(100) << endl;

        return 0;
}
The error with icc is:
Code:
/usr/include/c++/4.3.2/bits/char_traits.h(266): error: identifier "__builtin_memchr" is undefined
        { return static_cast<const char_type*>(__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<char_type*>(__builtin_memmove(__s1, __s2, __n)); }
                                         ^

/usr/include/c++/4.3.2/bits/allocator.h(143): error: identifier "__is_empty" is undefined
    template<typename _Alloc, bool = __is_empty(_Alloc)>
                                     ^

/usr/include/c++/4.3.2/bits/allocator.h(143): error: function call is not allowed in a constant expression
    template<typename _Alloc, bool = __is_empty(_Alloc)>
                                     ^

/usr/include/c++/4.3.2/bits/allocator.h(143): error: type name is not allowed
    template<typename _Alloc, bool = __is_empty(_Alloc)>
                                                ^

/usr/include/c++/4.3.2/bits/allocator.h(160): error: identifier "__is_empty" is undefined
    template<typename _Alloc, bool = __is_empty(_Alloc)>
                                     ^

/usr/include/c++/4.3.2/bits/allocator.h(160): error: function call is not allowed in a constant expression
    template<typename _Alloc, bool = __is_empty(_Alloc)>
                                     ^

/usr/include/c++/4.3.2/bits/allocator.h(160): error: type name is not allowed
    template<typename _Alloc, bool = __is_empty(_Alloc)>
                                                ^

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

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

compilation aborted for function_objects.cpp (code 2)
Help please!

TIA,
-S
 
Old 06-12-2009, 03:41 AM   #2
giftlftr_23
Member
 
Registered: Oct 2008
Location: I live where I'm currently standing on
Distribution: fedora, opensuse
Posts: 34

Rep: Reputation: 17
I never used a icc before but I'm guessing the icc is using the g++ includes not its own includes.
 
Old 06-12-2009, 03:47 AM   #3
Sinedie
Member
 
Registered: Nov 2006
Posts: 71

Original Poster
Rep: Reputation: 15
Yes, I tried reinstalling it. It didn't work. ICC uses its env variables set in iccvars.sh. So that should not be a reason.
 
Old 06-12-2009, 03:53 AM   #4
giftlftr_23
Member
 
Registered: Oct 2008
Location: I live where I'm currently standing on
Distribution: fedora, opensuse
Posts: 34

Rep: Reputation: 17
Why not post in icc support?
 
Old 06-12-2009, 04:07 AM   #5
Sinedie
Member
 
Registered: Nov 2006
Posts: 71

Original Poster
Rep: Reputation: 15
Because I was not sure if it was something that conforms to C++ standards (despite -ansi -pedantic -Wall). This was the first time I used something like x(0) which I did not see earlier in the material I read to be a proper way to initialize.
 
Old 06-12-2009, 04:16 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
It compiles well using icpc on my system (CentOS 5.3), just doing
Code:
icpc code.c
.
 
Old 06-12-2009, 04:17 AM   #7
giftlftr_23
Member
 
Registered: Oct 2008
Location: I live where I'm currently standing on
Distribution: fedora, opensuse
Posts: 34

Rep: Reputation: 17
The problem is not something to do with the conformance with standard c++ syntax but about the wrong includes your icc is reading. Post this problem to the icc support so that they can help with your problem.
 
Old 06-12-2009, 12:43 PM   #8
Sinedie
Member
 
Registered: Nov 2006
Posts: 71

Original Poster
Rep: Reputation: 15
I downloaded the latest icc. It works with issues. Will post it in the Intel forum as a bug report.
 
Old 06-12-2009, 01:02 PM   #9
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Have you tried with icpc (the intel C++ compiler)? If I try to compile it using icc I get a catastrophic error, whereas using icpc it compiles without a glitch.
 
Old 06-13-2009, 01:51 AM   #10
Sinedie
Member
 
Registered: Nov 2006
Posts: 71

Original Poster
Rep: Reputation: 15
It gave the same error with both with v10.1.008. With the current version (v11) even icc works.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[BUG] Current pkgtools installpkg bug jazzor Slackware 7 04-16-2009 05:30 AM
dhcp bug or bug in my head belda Linux - Networking 2 01-26-2008 08:46 AM
LXer: 2008 CES: Bug Labs Introduces BUG, BUGbase. So Cool! LXer Syndicated Linux News 0 01-09-2008 01:21 AM
2038 bug-Is Debian Bug-Proof? deepclutch Debian 1 08-02-2007 10:59 AM
Free86 bug or nVidia bug?? ProtoformX Linux - Software 2 05-12-2004 02:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration