This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/1731: Internal compiler error 191 for inherited overloaded operator[] on NULL



>Number:         1731
>Category:       c++
>Synopsis:       Internal compiler error 191 for inherited overloaded operator[] on NULL
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 22 09:56:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Kees van Reeuwijk
>Release:        gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
Debian linux 2.2
>Description:
This is a refinement of my bug report c++/1065 of
december 2000: I have simplified the example program considerably.

The following C++ program causes an internal compiler error:

--------
class ShapeBase
{
  public:
    int& operator[]( const int i ) const { 0; }
 
};
 
class ShapeD1: public ShapeBase
{
};
 
int main( int argc, char *argv[] )
{
    int n = (*(ShapeD1 *) 0)[0];
}                                                          ---------------

The fact that operator[] is inherited is important:
replacing ShapeD1 with ShapeBase in main() causes the
problem to go away.

It may be argued that the shown program is incorrect, since it tries to use a NULL pointer, but that's not a reason for an ICE. Moreover, constant propagation by the
compiler can cause the same situation and hence the same ICE.
>How-To-Repeat:
Compile the program above. No special flags are necessary.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]