ICE in this version of G++, my previous Debian version worked.
Compiling a method of a class that subclasses a template that
contains inline assembly code (used for atomic instructions),
see complete code snippet below. Command line "g++ -c foo.c"
yields error message:
g++_bug.cxx: In member function void LatchC::latch(int) volatile:
g++_bug.cxx:34: internal compiler error: in cp_expr_size, at
cp/cp-objcp-common.c:101
template <class T>
class AtomicM
{
public:
AtomicM(T i = T()) : val(i) { }
AtomicM(const AtomicM& from) : val(from.val) { }
AtomicM& operator=(const AtomicM& from)
{ exchange(from.val); return *this; }
inline T exchangeCmp(T e, T comparand) volatile
{
register int eax asm("eax") = comparand;
__asm__ __volatile__(
"lock; cmpxchg %2,%0"
: "+m" (val)
, "+a" (eax)
: "q" (e)
: "cc"
);
return (T)eax;
}
protected:
volatile T val;
};
class LatchC
: private AtomicM<int>
{
public:
inline void latch(int i) volatile
{
while (exchangeCmp(i, 0) != 0)
yield(1);
}
void enter();
private:
static void yield(int ms);
};
void
LatchC::enter()
{
latch(1);
}
--
Summary: g++ ICE in cp_expr_size expanding template with inline
assembly
Product: gcc
Version: 4.0.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cjh at managesoft dot com
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26592