This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/15881] New: Incorrect error on legal C++
- From: "dalej at apple dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jun 2004 19:47:07 -0000
- Subject: [Bug tree-optimization/15881] New: Incorrect error on legal C++
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Compile the following on lno-branch with g++ -O2 and watch the crash.
Some analysis follows example:
class QGArray
{
public:
char *at (unsigned int index) const { return &shd[index]; }
char *shd;
};
template<class type>
class QMemArray : public QGArray
{
public:
type& operator[]( int i ) const
{ return (type &)(*(type *)QGArray::at(i*sizeof(type))); }
};
struct QLayoutStruct
{
bool empty;
};
class QGridLayoutData
{
int rr;
int findSize (int QLayoutStruct::*) const;
QMemArray<QLayoutStruct> rowData;
};
int QGridLayoutData::findSize( int QLayoutStruct::*size ) const
{
int h = 0;
int n = 0;
for ( int r = 0; r < rr; r++ ) {
h = h + rowData[r].*size;
if ( !rowData[r].empty )
n++;
}
return n * h;
}
The key
difficulty is
h = h + rowData[r].*size;
which is gimplified into
size.6<D1654>_15 = (int<D2>)size<D1640>_14;
T.7<D1655>_16 = T.5<D1653>_13 + size.6<D1654>_15;
The code that looks for induction variables tries to analyze
(int<D2>)size<D1640>_14
and winds up trying to do the conversion at compile time through this chain of calls:
interpret_rhs_modify_expr
chrec_convert
convert
ocp_convert
convert_to_integer
which crashes with
3683113.sm.cc:25: error: aggregate value used where an integer was expected
I'm not familiar enough with ptr-to-member to figure out what it ought to be doing, but this isn't it.
--
Summary: Incorrect error on legal C++
Product: gcc
Version: lno
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dalej at apple dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: powerpc-apple-darwin7.3.0
GCC host triplet: powerpc-apple-darwin7.3.0
GCC target triplet: powerpc-apple-darwin7.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15881