Bug 49188 - C++ type conversion bug (gcc-2.96-85)
Summary: C++ type conversion bug (gcc-2.96-85)
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-07-16 18:58 UTC by Mumit Khan
Modified: 2007-04-18 16:34 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-10-05 18:20:46 UTC
Embargoed:


Attachments (Terms of Use)

Description Mumit Khan 2001-07-16 18:58:36 UTC
Bug details:
============

GCC 2.96 20000731 fails for the following C++ code. It is a regression from
GCC 2.95.x, and it doesn't fail for FSF GCC 3.0 release.

System and GCC RPM information
===============================
$ cat /etc/issue
Red Hat Linux release 7.1 (Seawolf)
Kernel 2.4.3-12 on an i686

[ All packages up-to-date as of 2001-07-12 using up2date ]

$ rpm -qa|grep gcc
gcc-objc-2.96-85
gcc-2.96-85
gcc-g77-2.96-85
gcc-c++-2.96-85
gcc-chill-2.96-85
gcc-java-2.96-85
$ rpm -qa|grep libstdc++
libstdc++-2.96-85
libstdc++-devel-2.96-85

Source
======
$ cat cxx-parse-bug.cc
struct
Foo
{
public:
  typedef void* (*copier_fn)(void const*);
  void foo() const;
  void bar(char const*, void const*) const;

private:
  struct
  Bar
  {
    char const* key;
    void const* item;
  };
};

void
Foo::foo() const
{
  Bar* cp = 0;                          // doesn't matter what it points
to.
  copier_fn copyfn = 0;                 // Likewise.

  bar(cp->key, cp->item);                               // Works as
expected.
  bar(cp->key, (copyfn) ? (*copyfn)(cp) : 0);           // Likewise.
  bar(cp->key, (copyfn) ? (*copyfn)(0) : 0);            // Likewise.
 
  bar(cp->key, (copyfn) ? (*copyfn)(0) : cp->item);     // Doesn't work.
  bar(cp->key, (copyfn) ? (*copyfn)(cp) : cp->item);    // Likewise.
}
 
 
Compiler invocation and error output
====================================
 
$ gcc -c -v cxx-parse-bug.cc
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-85)
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/cpp0 -lang-c++ -D__GNUG__=2
-D__EXCEPTIONS -v -D__GNUC__=2 -D__GNUC_MINOR__=96 -D__GNUC_PATCHLEVEL__=0
-D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix
-D__linux -Asystem(posix) -D__NO_INLINE__ -Acpu(i386) -Amachine(i386)
-Di386 -D__i386 -D__i386__ -D__tune_i386__ cxx-parse-bug.cc
/tmp/cc3MbEz4.ii
GNU CPP version 2.96 20000731 (Red Hat Linux 7.1 2.96-85) (cpplib) (i386
Linux/ELF)
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++-3
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/cc1plus /tmp/cc3MbEz4.ii -quiet
-dumpbase cxx-parse-bug.cc -version -o /tmp/ccebb390.s
GNU C++ version 2.96 20000731 (Red Hat Linux 7.1 2.96-85)
(i386-redhat-linux) compiled by GNU C version 2.96 20000731 (Red Hat Linux
7.1 2.96-85).
cxx-parse-bug.cc: In method `void Foo::foo () const':
cxx-parse-bug.cc:28: could not convert `cp->Foo::Bar::item' to `void *'
cxx-parse-bug.cc:29: could not convert `cp->Foo::Bar::item' to `void *'

Comment 1 Jakub Jelinek 2001-07-17 07:42:25 UTC
Patch is in my tree, will be fixed in gcc-c++-2.96-95.

Comment 2 Miloslav Trmac 2004-03-08 13:53:20 UTC
Fix confirmed in gcc-3.3.2-1.

Comment 3 Vladimir Makarov 2004-10-05 18:20:46 UTC
gcc-2.96 is too old.  Its release cycle was finished long ago.  Also
Jakub wrote about fixing it in gcc-2.96-95.  I can confirm that it was
fixed in redhat gcc-3.2 branch too.  So I am closing the case.  If it
is still important, we could reopen it.



Note You need to log in before you can comment on or make changes to this bug.