public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* template problem with 971016
@ 1997-10-21 12:40 dave madden
  1997-10-21 13:48 ` Joe Buck
  0 siblings, 1 reply; 5+ messages in thread
From: dave madden @ 1997-10-21 12:40 UTC (permalink / raw)
  To: egcs

Dunno if this is of any interest or help, but on "gcc version
egcs-2.90.13 971016 (gcc2-970802 experimental)" on an alpha (OSF4.0)
I've encountered a problem with templates: if you try to insert() a a
key-value pair<> into a multimap<>, the signature selection code won't
treat a pair<k,v> as an acceptable match for the pair<const k,v> that
it wants.

BTW, should I do anything special to get egcs to work with
libg++-2.7.2?  I get warnings from egcs about the new() and delete()
declared in g++-include/new.h.

regards,
d.

Script started on Tue Oct 21 12:03:03 1997
bash$ cat foo.cc
#include <multimap.h>

typedef multimap<int,char*>	 intptrmap;
typedef pair<int,char*>		 intptrpair;

int
main( int /*argc*/, char ** /*argv*/ )
{
	intptrmap	 m;

	m.insert( intptrpair( 1, "hello" ) );
}
bash$ egcs -v foo.cc
Reading specs from /usr/local/lib/gcc-lib/alphaev56-dec-osf4.0/egcs-2.90.13/specs
gcc version egcs-2.90.13 971016 (gcc2-970802 experimental)
 /usr/local/lib/gcc-lib/alphaev56-dec-osf4.0/egcs-2.90.13/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -Dunix -D__osf__ -D__alpha -D__alpha__ -D_LONGLONG -DSYSTYPE_BSD -D_SYSTYPE_BSD -D__unix__ -D__osf__ -D__alpha -D__alpha__ -D_LONGLONG -D__SYSTYPE_BSD__ -D_SYSTYPE_BSD -D__unix -D__SYSTYPE_BSD -Asystem(unix) -Asystem(xpg4) -Acpu(alpha) -Amachine(alpha) -D__EXCEPTIONS -D__LANGUAGE_C__ -D__LANGUAGE_C -DLANGUAGE_C -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus -I/usr/local/include/SGI-STL foo.cc /tmp/ccaaziua.ii
GNU CPP version egcs-2.90.13 971016 (gcc2-970802 experimental)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/SGI-STL
 /usr/local/include/g++
 /usr/local/lib/g++-include
 /usr/local/include
 /usr/local/alphaev56-dec-osf4.0/include
 /usr/local/lib/gcc-lib/alphaev56-dec-osf4.0/egcs-2.90.13/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/alphaev56-dec-osf4.0/egcs-2.90.13/cc1plus /tmp/ccaaziua.ii -quiet -dumpbase foo.cc -version -o /tmp/ccaaziua.s
GNU C++ version egcs-2.90.13 971016 (gcc2-970802 experimental) (alphaev56-dec-osf4.0) compiled by GNU C version 2.7.2.
In file included from /usr/local/lib/g++-include/new.h:6,
                 from /usr/local/include/SGI-STL/algobase.h:35,
                 from /usr/local/include/SGI-STL/tree.h:53,
                 from /usr/local/include/SGI-STL/multimap.h:30,
                 from foo.cc:1:
/usr/local/lib/g++-include/std/new.h:26: warning: declaration of `operator delete(void *)' throws different exceptions
<internal>:26: warning: previous declaration here
/usr/local/lib/g++-include/std/new.h:27: warning: declaration of `operator delete [](void *)' throws different exceptions
<internal>:27: warning: previous declaration here
foo.cc: In function `int main(int, char **)':
foo.cc:11: no matching function for call to `multimap<int,char *,less<int>,__default_alloc_template<false,0> >::insert (pair<int,char *>)'
/usr/local/include/SGI-STL/multimap.h:138: candidates are: multimap<int,char *,less<int>,__default_alloc_template<false,0> >::insert<int, char *, less<int>, __default_alloc_template<false,0>>(__rb_tree_iterator<pair<const int,char *>,const pair<const int,char *> &,const pair<const int,char *> *>, __rb_tree_iterator<pair<const int,char *>,const pair<const int,char *> &,const pair<const int,char *> *>)
/usr/local/include/SGI-STL/multimap.h:135:                 multimap<int,char *,less<int>,__default_alloc_template<false,0> >::insert<int, char *, less<int>, __default_alloc_template<false,0>>(const pair<const int,char *> *, const pair<const int,char *> *)
/usr/local/include/SGI-STL/multimap.h:126:                 multimap<int,char *,less<int>,__default_alloc_template<false,0> >::insert<int, char *, less<int>, __default_alloc_template<false,0>>(__rb_tree_iterator<pair<const int,char *>,pair<const int,char *> &,pair<const int,char *> *>, const pair<const int,char *> &)
/usr/local/include/SGI-STL/multimap.h:125:                 multimap<int,char *,less<int>,__default_alloc_template<false,0> >::insert<int, char *, less<int>, __default_alloc_template<false,0>>(const pair<const int,char *> &)
bash$ exit

script done on Tue Oct 21 12:03:13 1997

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: template problem with 971016
  1997-10-21 12:40 template problem with 971016 dave madden
@ 1997-10-21 13:48 ` Joe Buck
  1997-10-21 15:50   ` dave madden
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Buck @ 1997-10-21 13:48 UTC (permalink / raw)
  To: dave madden; +Cc: egcs

> I've encountered a problem with templates: if you try to insert() a a
> key-value pair<> into a multimap<>, the signature selection code won't
> treat a pair<k,v> as an acceptable match for the pair<const k,v> that
> it wants.

No, you've encountered a problem because you're using the wrong definition
of pair<>, one that you've gotten from SGI instead of using the EGCS
version (which is just the SGI version with the correct configuration
information -- you might be able to fix it by changing the SGI configuration
to say that member templates are supported).  Your code works fine when
you link against the provided headers.

SGI STL will only allow you to use pair<k,v> where pair<const k,v> is
desired if __STL_MEMBER_TEMPLATES is defined.  That's because it is
relying on the following templated constructor:

template <class T1, class T2>
struct pair {
	...
    template <class U1, class U2>
    pair(const pair<U1, U2>& p) : first(p.first), second(p.second) {}
};

As you can see, this allows any pair to be constructed from any other.

> BTW, should I do anything special to get egcs to work with
> libg++-2.7.2?  I get warnings from egcs about the new() and delete()
> declared in g++-include/new.h.

Why would you want to do this?  If you're hoping that this will allow you
to link egcs-generated code to 2.7.2-generated code, I'm afraid you're
going to have problems -- you'd need to turn off a number of things to
get the code to match.  If you need stuff in the old libg++, you're
better off starting with libg++-2.8.0b6, which you can find on
ftp.cygnus.com/pub/g++, though there may be a newer version.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: template problem with 971016
  1997-10-21 15:50   ` dave madden
@ 1997-10-21 15:50     ` Joe Buck
  1997-10-21 16:11       ` libg++ header file locations dave madden
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Buck @ 1997-10-21 15:50 UTC (permalink / raw)
  To: dave madden; +Cc: jbuck, egcs

> Actually, I'm not (currently) using anything in libg++, but the old
> header files are seen by egcs++ due to search paths, and the old
> declarations of new & delete conflict.

I don't understand why: gcc/libg++ used to use $prefix/lib/g++-include for
headers; egcs uses $prefix/usr/include.  So I don't understand where
you are getting old headers from.  Do you have stuff in /usr/local/include?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: template problem with 971016
  1997-10-21 13:48 ` Joe Buck
@ 1997-10-21 15:50   ` dave madden
  1997-10-21 15:50     ` Joe Buck
  0 siblings, 1 reply; 5+ messages in thread
From: dave madden @ 1997-10-21 15:50 UTC (permalink / raw)
  To: jbuck; +Cc: egcs

 =>From: Joe Buck <jbuck@synopsys.com>
 =>
 =>> I've encountered a problem with templates: if you try to insert() a a
 =>> key-value pair<> into a multimap<>, the signature selection code won't
 =>> treat a pair<k,v> as an acceptable match for the pair<const k,v> that
 =>> it wants.
 =>
 =>No, you've encountered a problem because you're using the wrong definition
 =>of pair<>, one that you've gotten from SGI instead of using the EGCS
 =>version ...
 =>Your code works fine when you link against the provided headers.

OK, thanks!

 =>> BTW, should I do anything special to get egcs to work with
 =>> libg++-2.7.2?  I get warnings from egcs about the new() and delete()
 =>> declared in g++-include/new.h.
 =>
 =>Why would you want to do this?
 =>...
 =>If you need stuff in the old libg++, you're
 =>better off starting with libg++-2.8.0b6...

Actually, I'm not (currently) using anything in libg++, but the old
header files are seen by egcs++ due to search paths, and the old
declarations of new & delete conflict.  I'll try libg++-2.8.0; is
there any reason this isn't linked into the egcs area (either via
symlink or note in a README), since it's easily foreseeable that an
egcs user might be interested in it?

regards,
d.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* libg++ header file locations...
  1997-10-21 15:50     ` Joe Buck
@ 1997-10-21 16:11       ` dave madden
  0 siblings, 0 replies; 5+ messages in thread
From: dave madden @ 1997-10-21 16:11 UTC (permalink / raw)
  To: jbuck; +Cc: egcs

 =>From: Joe Buck <jbuck@synopsys.com>
 =>
 =>> Actually, I'm not (currently) using anything in libg++, but the old
 =>> header files are seen by egcs++ due to search paths, and the old
 =>> declarations of new & delete conflict.
 =>
 =>I don't understand why: gcc/libg++ used to use $prefix/lib/g++-include for
 =>headers; egcs uses $prefix/usr/include.  So I don't understand where
 =>you are getting old headers from.  Do you have stuff in /usr/local/include?

Yes; I have a bunch of different gcc's running on the machine
(2.7.2.2, a gcc cross-compiler for USR PalmPilots, and egcs), and I
don't fully understand where things *should* be installed.  (OTOH, I'm
not *that* dumb; I hope it's not all my fault that things are a little
confused :-)

The include path egcs++ searches on my machine is:

 /usr/local/include/SGI-STL <- I added this (contains the SGI STL headers)
 /usr/local/include/g++     <- I guess this was found during the build?
                               Maybe the PalmPilot install put it there.
                               I don't think I did it myself, except as
                               part of some other install.
 /usr/local/lib/g++-include <- this is where the plain libg++-2.7.2 lives
 /usr/local/include         <- some PalmPilot stuff is here
 /usr/local/alphaev56-dec-osf4.0/include
 /usr/local/lib/gcc-lib/alphaev56-dec-osf4.0/egcs-2.90.13/include

I guess I should really clean out /usr/local/include, rebuild the
compilers, and install all the headers that are appropriate for a
version down the $prefix/lib/gcc-lib/version.../ tree, where cc1 &
friends live.

d.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1997-10-21 16:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-21 12:40 template problem with 971016 dave madden
1997-10-21 13:48 ` Joe Buck
1997-10-21 15:50   ` dave madden
1997-10-21 15:50     ` Joe Buck
1997-10-21 16:11       ` libg++ header file locations dave madden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).