- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The icc 7.0 for linux seems to break code using function templates when compiled with optimization enabled. The following command line arguments are used for compiling:
-x c++ -Xa -align -Zp16 -w1 -c -D__null=0 -O3 -mp1 -rcd -tpp6 -axM -ip
The offending code is a bit too long to post it here completely, but the following code snipped may give an impression:
typedef unsigned short UWORD;
class Foo {
/* snip */
typedef UWORD (Foo::*MicroCode)(UWORD operand);
template
UWORD Cat(UWORD operand)
{
return (this->*step2)((this->*step1)(operand));
}
UWORD ImmediateUnit(UWORD)
{
return Ram->ReadByte(GlobalPC++);
}
template
UWORD OrToStatusUnit(UWORD)
{
return GlobalP |= mask;
}
template
UWORD LoadPCUnit(UWORD)
{
return GlobalPC + displacement;
}
UWORD PushUnit(UWORD operand)
{
Stack[UBYTE(GlobalS--)] = operand;
return operand;
}
/* snip */
void BuildInstructions(void);
void AddStep(MicroCode step);
};
Then, in the .cpp file, I take pointers to templated member functions:
void Foo::BuildInstructions(void)
{
/* snip */
AddStep(&CPU::Cat<&CPU::OrToStatusUnit,&CPU::PushU
nit>);
/* snip */
}
The code compiles file, but the resulting program is corrupt and executes the wrong functions,i.e. template arguments are resolved incorrectly. The code runs fine if compiled with GNU GCC 3.2.1, and it also runs fine if compiled without the optimizer. The same bug applies to the icc 6.0 compiler.
For a complete (but lengthy) source code, please contact me at thor@math.tu-berlin.de. Please post comments to this mail as well.
Best regards,
Thomas Richter
-x c++ -Xa -align -Zp16 -w1 -c -D__null=0 -O3 -mp1 -rcd -tpp6 -axM -ip
The offending code is a bit too long to post it here completely, but the following code snipped may give an impression:
typedef unsigned short UWORD;
class Foo {
/* snip */
typedef UWORD (Foo::*MicroCode)(UWORD operand);
template
UWORD Cat(UWORD operand)
{
return (this->*step2)((this->*step1)(operand));
}
UWORD ImmediateUnit(UWORD)
{
return Ram->ReadByte(GlobalPC++);
}
template
UWORD OrToStatusUnit(UWORD)
{
return GlobalP |= mask;
}
template
UWORD LoadPCUnit(UWORD)
{
return GlobalPC + displacement;
}
UWORD PushUnit(UWORD operand)
{
Stack[UBYTE(GlobalS--)] = operand;
return operand;
}
/* snip */
void BuildInstructions(void);
void AddStep(MicroCode step);
};
Then, in the .cpp file, I take pointers to templated member functions:
void Foo::BuildInstructions(void)
{
/* snip */
AddStep(&CPU::Cat<&CPU::OrToStatusUnit
nit>);
/* snip */
}
The code compiles file, but the resulting program is corrupt and executes the wrong functions,i.e. template arguments are resolved incorrectly. The code runs fine if compiled with GNU GCC 3.2.1, and it also runs fine if compiled without the optimizer. The same bug applies to the icc 6.0 compiler.
For a complete (but lengthy) source code, please contact me at thor@math.tu-berlin.de. Please post comments to this mail as well.
Best regards,
Thomas Richter
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Thomas:
Do you have an account on Premier support? You can always create one and submit issues through there. And that way we can deliver a newer compiler to you after the problem is fixed.
I'll also contact you directly.
Thanks very much for reporting the issue.
Jennifer
Do you have an account on Premier support? You can always create one and submit issues through there. And that way we can deliver a newer compiler to you after the problem is fixed.
I'll also contact you directly.
Thanks very much for reporting the issue.
Jennifer
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page