c++/680: STL <bitset> that comes with g++

dharmash@ecn.purdue.edu dharmash@ecn.purdue.edu
Mon Oct 23 13:46:00 GMT 2000


>Number:         680
>Category:       c++
>Synopsis:       STL <bitset> that comes with g++
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 23 13:46:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     dharmash@ecn.purdue.edu
>Release:        2.95.2
>Organization:
>Environment:
Sun, g++ 2.95.2
>Description:
The <bitset> header that comes with g++ calls a function,
push_back(char) on a string.
But function push_back is not defined in the string header (which includes the bastring header).
So compilation fails.
Further, one cannot create a bitset from a string, due to link errors.
One cannot test a position in the bitset due to link failures. Please see the attached file. It is very small, does not link because, g++ says:

Undefined                       first referenced
 symbol                             in file
out_of_range::out_of_range(basic_string<char, string_char_traits<char>, __default_alloc_template<false, 0> > const &)/var/tmp/ccCryPZg.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
>How-To-Repeat:
Just say,
g++ bittest.C
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="bittest.C"
Content-Disposition: inline; filename="bittest.C"

#include <iostream>
#include <fstream>
#include <climits>
#include <bitset>
#include <cmath>
int main(){
	ifstream out;
	out.open("bittry.txt");
       char nl = 'a';
        char nl2 = 'n';
        char nl3 = 'u';
	int winchar = (int) (pow(2, 12));
	bitset< 24 > set1(winchar);
	bitset<8> set2('\t');
	bitset<8> set3('X');
	bitset<8> set4(nl);
        bitset<8> set5(nl2);
	bitset<8> set6(nl3);
	set6.test(2);
        
/*	bitset<24> first;
	out >> first;
     	cout << first.to_ulong() << endl;
    	bitset<8> sec;
	out >> sec;
	cout << sec.to_ulong() << endl;
	out >> sec;
 	cout << sec.to_ulong() << endl;
	out >> sec;
	cout << sec.to_ulong() << endl;
	out >> sec;
	cout << sec.to_ulong() << endl;
	out >> sec;
	cout << sec.to_ulong() << endl;
	out.close();
	*/
	cout << pow(2, 12) << endl;
	return -1;	
}


More information about the Gcc-bugs mailing list