X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: Alex Vinokur Newsgroups: comp.os.msdos.djgpp,comp.lang.c++ Subject: Error with bind2nd() and ptr_fun() Date: Thu, 07 Feb 2002 12:10:40 +0200 Lines: 134 Message-ID: <3C62529F.D7F259FA@bigfoot.com> References: <3C624DA4 DOT CDAF6FC3 AT bigfoot DOT com> NNTP-Posting-Host: 62.90.123.5 Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1013076633 45126180 62.90.123.5 (16 [79865]) X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com =============================================================== Windows98 gpp : GNU C++ version 2.95.3 20010315/djgpp (release) (djgpp) compiled by GNU C version 2.95.3 20010315/djgpp (release). =============================================================== Here is a program and compilation results. The compiler detects some error and informs about "Internal compiler error". Is there an error in my program? Or "Internal compiler error" caused that (!?) Thanks. //============= C++ Code : BEGIN ============= #include #include #include #include #include #include // ------------------------------- class AAA { private : string name_; int value_; public : AAA () {} AAA (const string& name_i, int value) : name_ (name_i), value_ (value) {} ~AAA () {} int get_value () {return value_;} void set_value (int value) {value_ = value;} }; // --------------------------- int foo1 (AAA& inst) { inst.set_value (inst.get_value() + 100); return inst.get_value(); } // --------------------------- int foo2 (AAA& inst, int value) { inst.set_value (inst.get_value() + value); return inst.get_value(); } // --------------------------- int main() { vector vect; vect.push_back( AAA("xxx", 3) ); vect.push_back( AAA("yyy", 5) ); for_each(vect.begin(), vect.end(), foo1); for_each(vect.begin(), vect.end(), ptr_fun (foo1)); for_each(vect.begin(), vect.end(), bind2nd(ptr_fun(foo2), 200)); // Line#53 return 0; } //============= C++ Code : END =============== //=========== Compilation : BEGIN ============ %gpp aaa.c d:/sys/djgpp/lang/cxx/stl_function.h: In instantiation of `binder2nd >': d:/sys/djgpp/lang/cxx/stl_function.h:231: instantiated from `bind2nd, int>(const pointer_to_binary_function &, const int &)' aaa.c:53: instantiated from here d:/sys/djgpp/lang/cxx/stl_function.h:223: forming reference to reference type `AAA &const' d:/sys/djgpp/lang/cxx/stl_function.h:223: `binder2nd >::operator ()(...)' must be a nonstatic member function d:/sys/djgpp/lang/cxx/stl_algo.h: In function `class binder2nd > for_each > >(AAA *, AAA *, binder2nd >)': aaa.c:53: instantiated from here d:/sys/djgpp/lang/cxx/stl_algo.h:83: warning: cannot pass objects of type `AAA' through `...' d:/sys/djgpp/lang/cxx/stl_function.h: At top level: d:/sys/djgpp/lang/cxx/stl_function.h: In instantiation of `binder2nd >::operator ()(...)': d:/sys/djgpp/lang/cxx/stl_algo.h:83: instantiated from `for_each > >(AAA *, AAA *, binder2nd >)' aaa.c:53: instantiated from here d:/sys/djgpp/lang/cxx/stl_function.h:223: `binder2nd >::operator ()(...)' must be a nonstatic member function d:/sys/djgpp/lang/cxx/stl_function.h: In function `{error} binder2nd >::operator ()(...)': d:/sys/djgpp/lang/cxx/stl_function.h:223: Internal compiler error in `layout_decl', at stor-layout.c:247 Please submit a full bug report. See for instructions. //=========== Compilation : END ============== =========================== Alex Vinokur mailto:alexvn AT bigfoot DOT com mailto:alexvnw AT yahoo DOT com http://up.to/alexvn http://go.to/alexv_math ===========================