Bug 102375 - g++ 2.96 STL Mishandles Static Members as Parameters
Summary: g++ 2.96 STL Mishandles Static Members as Parameters
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.3
Hardware: athlon
OS: Linux
high
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-08-14 16:42 UTC by Bill Maniatty
Modified: 2007-03-27 04:08 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-10-01 21:22:55 UTC
Embargoed:


Attachments (Terms of Use)

Description Bill Maniatty 2003-08-14 16:42:13 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.79 [en] (X11; U; Linux 2.4.20-18.7smp i686)

Description of problem:
Apparently there is some STL and g++ mismatch on my Redhat machines that
causes some (at least the deque) container classes member functions fail
to compile if their parameter is a static class member.   An simple source code
example with some detailed information in the comments is provided in
the "Additional Information" section of this bug report.

As far as I can tell the following C++ program is valid and Redhat's g++
compiler
doesn't handle it while an older version on my home's SuSE box can).  I can't
tell
for sure, but is it possible that there is a version mismatch between the STL
include
files and the g++ version?

Version-Release number of selected component (if applicable):
gcc-2.96-110
  gcc-c++-2.96-110

How reproducible:
Always

Steps to Reproduce:
1.Compile the attached program "g++ -g -Wall testbug.cpp"
2.See error message
3.
    

Actual Results:  Got the following error on C++ that seems valid to me:
g++ -g -Wall testbug.cpp
/tmp/ccYVqcFq.o: In function `_Deque_iterator<int, int &, int *,
0>::_S_buffer_size(void)':
/usr/include/g++-3/stl_deque.h:103: undefined reference to
`TestClass::SomeValue'
collect2: ld returned 1 exit status

Compilation exited abnormally with code 1 at Thu Aug 14 12:33:33
If you remove the -g flag, the compilation fails but the messages are less
informative.


Expected Results:  Successful compilation

Additional info:

/*----------------------------------------------------------------------
  File    : testbug.cpp
  Contents and Notes: exhibits a bug in STL compilation of g++ on redhat 7.3
  How to reproduce
  g++ -g -Wall testbug.cpp
  fails to compile this seemingly valid  program and gives the following errors:
/tmp/cctGii5x.o: In function `_Deque_iterator<int, int &, int *,
0>::_S_buffer_size(void)':
/usr/include/g++-3/stl_deque.h:103: undefined reference to
`TestClass::SomeValue'
collect2: ld returned 1 exit status
  Redhat version information (7.3 with some errata patches hand applied).
  uname -a 
  Linux xxx.xxx.edu  2.4.20-18.7smp #1 SMP Thu May 29 06:44:21 EDT 2003 i686
unknown
  rpm -q -a | grep gcc 
  gcc-objc-2.96-110
  gcc-2.96-110
  gcc-c++-2.96-110
  gcc-g77-2.96-110
  Note that this bug does not happen on my SuSE system which
  uname -a
  Linux xxx.xxx.com  #1 Wed Mar 27 13:57:05 UTC 2002 i686 unknown
  rpm -q -a | grep gcc
  gcc-2.95.3-216
  gccinfo-2.95.3-216

  Author  : Bill Maniatty
  Update  : 08/13/2003
  ----------------------------------------------------------------------*/


#include <deque>
#include <ostream.h>

using namespace std;

class TestClass
{
 private:
  // static int SomeValue; // Note this is private and static
  deque<int> *dptr;
  TestClass( const TestClass &original ){
    SomeValue = -1;
    cerr << "Copy Constructor invoked, should never happen\n";
  }
 public:
  static int SomeValue; // Note this is private and static
	
  TestClass(){
    // Would compile if SomeConstant was not a constant!
    dptr = new deque<int>;
  };
  ~TestClass(){ delete dptr; };
  bool empty(){ return dptr->size() == 0; }
  void insert(){
    dptr->push_back(SomeValue); // Can't Compile STL of this line properly!
  };
};

int
main(){
  TestClass testobject;
  testobject.insert();
  return 0;
}

Comment 1 Bill Maniatty 2003-08-14 16:54:34 UTC
I gave it high priority since valid programs don't compile properly in this
environment,
but labeled it as normal in severity since it doesn't crash or hang the system.

On a side note, the SUSE linux version does not compile this test case, but the
code
it was derived from did compile under SUSE, I'll  need to check more closely
whether there
is a standards violation or not in the code.

Comment 2 Benjamin Kosnik 2004-10-01 21:22:55 UTC
Fixed with gcc-3.2.x, gcc-3.3.x, gcc-3.4.x




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