This is the mail archive of the gcc-bugs@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++/1934: Crash on bad member name



>Number:         1934
>Category:       c++
>Synopsis:       Crash on bad member name
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 11 10:56:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     sean.middleditch@iname.com
>Release:        2.95.3 19991030 (prerelease)
>Organization:
>Environment:
Linux-Mandrake 7.2
Linux sean.aweplay 2.2.17-21mdk #1 Thu Oct 5 13:16:08 CEST 2000 i686 unknown
PII 450, 128MB RAM
>Description:
I had a class that had a vector<> member named 'list' to store data.  I converted the code to use a list<> type instead.  After including the list header file, I had to change my member variables' names from list to clist (for obvious reasons).

Previous declaration:
#include <vector.h>
class data
{
	public:
	vector<data> list;
};

New declaration:
#include <list.h>
class data
{
	public:
	list<data> clist;
}

In a few spots in the code, the references to 'list' did not get changed to 'clist'.

The class (named data) thus had a 'list<data> clist' member.  However, if a list<data>::iterator variable tried to reference the member list (instead of clist) such as in

  for (list<data>::iterator i = clist.begin (); i != clist.end (); i ++)
    if (i->list)  // <-- problem line, referencing 'list' instead of 'clist'
      return i->list;

This causes an internal compiler error, instead of reporting an invalid member name or whatnot.

I'd attach a copy of my code as an example, but it's rather large.  The project, btw, is AweMUD (awemud.sourceforge.net), and various examples of the problem code can be found in the CVS repository, in the files configure.cc and configure.h.
>How-To-Repeat:
The above code snippet explains what causes the problem.
>Fix:
To work around the crash, simply make sure you don't use a member name of 'list' when you are including the list.h header file.  As for making gcc not crash, and report an error like it should be, I have no idea.
>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]