Bug 74946 - g++ on RH8.0 does not see standard library types properly
Summary: g++ on RH8.0 does not see standard library types properly
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 8.0
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-10-02 23:16 UTC by Matt Kennel
Modified: 2007-04-18 16:47 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-10-03 03:43:20 UTC
Embargoed:


Attachments (Terms of Use)

Description Matt Kennel 2002-10-02 23:16:37 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020827

Description of problem:
For some reason in the g++ or libstdc++ installation the standard library types
do not seem to be visible to the compiler.  These are trivial programs which
work fine on Redhat 7.3.  This is serious since it is impossible to compile any
useful C++ program.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
% cat bug.cc
#include <sstream>
#include <string>

main() {
  string s("Hello standard library.\n"); 
  cout << "hello world\n" << s;
}


Actual Results:   g++ -o bug bug.cc
bug.cc: In function `int main()':
bug.cc:9: `string' undeclared (first use this function)
bug.cc:9: (Each undeclared identifier is reported only once for each function
   it appears in.)
bug.cc:9: parse error before `(' token
bug.cc:10: `cout' undeclared (first use this function)
bug.cc:10: `s' undeclared (first use this function)
[mbk@lyapunov ffs-adaptive]%


Expected Results:  % g++ -o bug bug.cc
% ./bug
hello world
Hello standard library.
%

Additional info:

g++ -v
[mbk@lyapunov ffs-adaptive]% g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
[mbk@lyapunov ffs-adaptive]%

% rpm -q -i gcc
Name        : gcc                          Relocations: (not relocateable)
Version     : 3.2                               Vendor: Red Hat, Inc.
Release     : 7                             Build Date: Tue 03 Sep 2002 08:04:33

Comment 1 Ali-Reza Anghaie 2002-10-03 03:43:15 UTC
For reference: 
 
[ali@damascus tt]$ cat /etc/redhat-release 
Red Hat Linux release 8.0 (Psyche) 
 
[ali@damascus tt]$ cat bug.cpp 
#include <iostream> 
#include <string> 
 
main() { 
        std::string s("Hello standard library.\n"); 
        std::cout << "hello world\n" << s; 
} 
 
[ali@damascus tt]$ g++ -o bug bug.cpp 
 
[ali@damascus tt]$ ./bug 
hello world 
Hello standard library. 
 
 
Cheers, -Ali

Comment 2 Jakub Jelinek 2002-10-03 11:33:29 UTC
The standard defines string, cout etc. in std namespace.
So, either you do ali suggested, or you add
using std::string;
using std::cout;
or you add
using namespace std;


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