This is the mail archive of the gcc@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]

Re: Problems with stl_vector and GCC 2.95.2 19991024


> 
> This is a multi-part message in MIME format.
> --------------703237F3698EA7218C6EAFED
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> 
> Hello,
> 
> SuSE 7.0 - Kernel 2.2.16
> 
> I'm trying to compile a product that makes use of the vector class from
> the standard template library, but have hit issues with parse errors.
> 
> I've simplified the issue with the following program:
> 
> 	#include <stl/stl_vector.h>
> 
> 	int main()
> 	{
>    	    vector<int> v(10,0);
>    	    return 0;
> 	}

The problem is confusion between two different constructors.  One
takes a size_t (the number of elements) and a const reference to
an element to fill with.  This is the one that you want.  The other
is a templated member function and takes two arguments of the same
type, treated as iterators.  This lets you do things like

// turn a set into a vector.
	void foo(const set<int>& some_set)
	{
		vector<int> v(some_set.begin(), some_set.end());
	}

It seems that the errors you're seeing come from an attempt to use the
member function version, though I don't quite understand them.

One possible workaround would be to write

	vector<int> v(10U, 0);

This will match the first constructor and not the second.

But I'm not sure what to tell you about vector<unsigned>.


> Compilation fails with the following (Please read past the errors)
> **************************************************
> In file included from test.cpp:1:
> /usr/include/g++/stl_vector.h:120: syntax error before `template'
> /usr/include/g++/stl_vector.h:124: syntax error before `('
> /usr/include/g++/stl_vector.h:126: parse error before `&'
> /usr/include/g++/stl_vector.h: In function `int _Vector_base(...)':
> /usr/include/g++/stl_vector.h:127: base initializers not allowed for
> non-member functions
> /usr/include/g++/stl_vector.h: At top level:
> /usr/include/g++/stl_vector.h:128: `size_t' was not declared in this
> scope
> /usr/include/g++/stl_vector.h:128: parse error before `,'
> /usr/include/g++/stl_vector.h: In function `int _Vector_base(...)':
> /usr/include/g++/stl_vector.h:129: redefinition of `int
> _Vector_base(...)'
> /usr/include/g++/stl_vector.h:127: `int _Vector_base(...)' previously
> defined here
> /usr/include/g++/stl_vector.h: In function `int _Vector_base(...)':
> /usr/include/g++/stl_vector.h:129: base initializers not allowed for
> non-member functions
> /usr/include/g++/stl_vector.h:131: `_M_start' undeclared (first use this
> function)
> /usr/include/g++/stl_vector.h:131: (Each undeclared identifier is
> reported only once
> /usr/include/g++/stl_vector.h:131: for each function it appears in.)
> /usr/include/g++/stl_vector.h:131: `__n' undeclared (first use this
> function)
> /usr/include/g++/stl_vector.h:131: implicit declaration of function `int
> _M_allocate(...)'
> /usr/include/g++/stl_vector.h:132: `_M_finish' undeclared (first use
> this function)
> /usr/include/g++/stl_vector.h:133: `_M_end_of_storage' undeclared (first
> use this function)
> /usr/include/g++/stl_vector.h: At top level:
> /usr/include/g++/stl_vector.h:136: destructors must be member functions
> /usr/include/g++/stl_vector.h: In function `void _Vector_base()':
> /usr/include/g++/stl_vector.h:136: implicit declaration of function `int
> _M_deallocate(...)'
> /usr/include/g++/stl_vector.h: At top level:
> /usr/include/g++/stl_vector.h:138: parse error before `protected'
> /usr/include/g++/stl_vector.h:140: syntax error before `*'
> /usr/include/g++/stl_vector.h:141: syntax error before `*'
> /usr/include/g++/stl_vector.h:143: `_Tp' was not declared in this scope
> /usr/include/g++/stl_vector.h:143: `_Alloc' was not declared in this
> scope
> /usr/include/g++/stl_vector.h:143: syntax error before `;'
> /usr/include/g++/stl_vector.h:144: syntax error before `*'
> /usr/include/g++/stl_vector.h:146: `_Tp' was not declared in this scope
> /usr/include/g++/stl_vector.h:146: `__p' was not declared in this scope
> /usr/include/g++/stl_vector.h:146: parse error before `)'
> /usr/include/g++/stl_vector.h: In function `void _M_deallocate(...)':
> /usr/include/g++/stl_vector.h:147: `_M_data_allocator' undeclared (first
> use this function)
> /usr/include/g++/stl_vector.h:147: parse error before `::'
> /usr/include/g++/stl_vector.h: At top level:
> /usr/include/g++/stl_vector.h:152: parse error before `('
> /usr/include/g++/stl_vector.h:159: syntax error before `*'
> /usr/include/g++/stl_vector.h:160: syntax error before `*'
> /usr/include/g++/stl_vector.h:161: syntax error before `*'
> /usr/include/g++/stl_vector.h:162: syntax error before `*'
> /usr/include/g++/stl_vector.h:163: syntax error before `&'
> /usr/include/g++/stl_vector.h:164: syntax error before `&'
> /usr/include/g++/stl_vector.h:165: syntax error before `;'
> /usr/include/g++/stl_vector.h:166: syntax error before `;'
> /usr/include/g++/stl_vector.h:168: `_Base' is not a class or namespace
> /usr/include/g++/stl_vector.h:168: `allocator_type' is not a class or
> namespace
> /usr/include/g++/stl_vector.h:168: `_Base' fails to be a typedef or
> built in type
> /usr/include/g++/stl_vector.h:168: confused by earlier errors, bailing
> out
> ********************************************************
> 
> The producers of the product stated that GCC 2.91.66 and above was
> necessary.  I've rolledback my compiler to that version.  When
> compiling, there were still errors, just fewer of them.  I also
> attempted to try 2.97 (latest snapshot) but never got the build process
> to work quite right.
> 
> Has anyone else seen this?  I didn't have much luck with the bug
> database.  If someone has, what, if anything, have you done to get
> around this?  Have any RedHat 7.0 users seen this as they are running
> 2.96 by default?
> 
> Thanks,
> 
> Ryan Lubke
> --------------703237F3698EA7218C6EAFED
> Content-Type: text/x-vcard; charset=us-ascii;
>  name="Ryan.Lubke.vcf"
> Content-Transfer-Encoding: 7bit
> Content-Description: Card for Ryan Lubke
> Content-Disposition: attachment;
>  filename="Ryan.Lubke.vcf"
> 
> begin:vcard 
> n:Lubke;Ryan
> tel;fax:781.442.1520
> tel;work:781.442.2408
> x-mozilla-html:FALSE
> url:http://www.sun.com
> org:Sun Microsystems;Webtop and Applications
> adr:;;One Network Drive;Burlington;MA;01803-UBUR-202;
> version:2.1
> email;internet:Ryan.Lubke@East.Sun.COM
> x-mozilla-cpt:;14560
> fn:Ryan Lubke
> end:vcard
> 
> --------------703237F3698EA7218C6EAFED--
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]