Hi! Version of g++ is: Reading specs from /usr/local/lib/gcc-lib/i386-unknown-freebsdelf/2.95.1/specs gcc version 2.95.1 19990816 (release) System type is: FreeBSD 3.2-STABLE Options and error: g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../libkonq -I/usr/local/include -I/usr/local/kde/include -I/usr/local/qt/include  -I/usr/X11R6/include    -O2 -c konq_childview.cc In file included from konq_childview.cc:23: konq_propsview.h:141: syntax error before `(' konq_propsview.h:143: warning: internal problem, current_class_type differs when adding `KfmViewSettings::~KfmViewSettings()', please report Best regards, Magnus >From knut@orion.no Thu Aug 26 05:42:00 1999 From: "Knut-Håvard Aksnes" To: gcc-bugs@gcc.gnu.org Subject: Optimization bug in C++ Date: Thu, 26 Aug 1999 05:42:00 -0000 Message-id: <14277.14092.685032.141452@knut.orion.no> X-SW-Source: 1999-08/msg00974.html Content-length: 9577 A rewrite of the bug report previously posted as "serious brain damage in C++ compiler" The C++ compiler does some very dangerous and optimizations. This breaks code conformant to the standard CORBA C++ bindings. The problem is the choice of cast operators, exemplified by these messages: SerialServant.cpp:19: warning: choosing `NO::orion::markfeed::Feed_var::operator NO::orion::markfeed::Feed *&()' over `NO::orion::markfeed::Feed_var::operator NO::orion::markfeed::Feed *const &() const' SerialServant.cpp:19: warning: for conversion from `NO::orion::markfeed::Feed_var' to `CORBA_Object *' SerialServant.cpp:19: warning: because conversion sequence for the argument is better Explicit casts are used in the code to ensure usage of the right conversion. The compiler seems to override these casts, this leads to serious memory leaks in corba code. Semantics of conversion operators in corba: X_var cast to X * The returned object is owned by the caller. X_var cast to const X * The returned object is owned by the X_var object. Using cast to pointer where cast to pointer to const is intended creates memory leaks, The SerialServant.ii.bz2 file can be found at: http://www.orion.no/SerialServant.ii.bz2 Output from compilation follows: cd /home/knut/devroot/src/NordPool/Markfeed/ c++ -v --save-temps -DPACKAGE=\"markfeed\" -DVERSION=\"2.91\" -DHAVE_LIBRT=1 -DHAVE_LIBRESOLV=1 -DHAVE_STRSTREAM=1 -I. -I. -DWITHOUT_NANA -D_GNU_SOURCE -DACE_HAS_GNU_REPO -DACE_LACKS_PRAGMA_ONCE -D_POSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -D_REENTRANT -I/usr/local/ACE_wrappers/TAO/orbsvcs/orbsvcs -I/usr/local/ACE_wrappers/TAO -I/usr/local/ACE_wrappers -frepo -pipe -g -O2 -c SerialServant.cpp c++: Warning: -pipe ignored since -save-temps specified Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/specs gcc version 2.95.1 19990816 (release) /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/cpp -lang-c++ -v -I. -I. -I/usr/local/ACE_wrappers/TAO/orbsvcs/orbsvcs -I/usr/local/ACE_wrappers/TAO -I/usr/local/ACE_wrappers -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -D__OPTIMIZE__ -g -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -DPACKAGE="markfeed" -DVERSION="2.91" -DHAVE_LIBRT=1 -DHAVE_LIBRESOLV=1 -DHAVE_STRSTREAM=1 -DWITHOUT_NANA -D_GNU_SOURCE -DACE_HAS_GNU_REPO -DACE_LACKS_PRAGMA_ONCE -D_POSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -D_REENTRANT SerialServant.cpp SerialServant.ii GNU CPP version 2.95.1 19990816 (release) (i386 Linux/ELF) #include "..." search starts here: #include <...> search starts here: . /usr/local/ACE_wrappers/TAO/orbsvcs/orbsvcs /usr/local/ACE_wrappers/TAO /usr/local/ACE_wrappers /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/../../../../include/g++-3 /usr/local/include /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/../../../../i686-pc-linux-gnu/include /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/include /usr/include End of search list. The following default directories have been omitted from the search path: End of omitted list. /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/cc1plus SerialServant.ii -quiet -dumpbase SerialServant.cc -g -O2 -version -frepo -o SerialServant.s GNU C++ version 2.95.1 19990816 (release) (i686-pc-linux-gnu) compiled by GNU C version 2.95.1 19990816 (release). SerialServant.cpp: In method `void NO::orion::markfeed::SerialServant::remove()': SerialServant.cpp:19: warning: choosing `NO::orion::markfeed::Feed_var::operator NO::orion::markfeed::Feed *&()' over `NO::orion::markfeed::Feed_var::operator NO::orion::markfeed::Feed *const &() const' SerialServant.cpp:19: warning: for conversion from `NO::orion::markfeed::Feed_var' to `CORBA_Object *' SerialServant.cpp:19: warning: because conversion sequence for the argument is better SerialServant.cpp: In method `void NO::orion::markfeed::SerialServant::disconnect_push_supplier()': SerialServant.cpp:36: warning: choosing `NO::orion::markfeed::PushConsumer_var::operator NO::orion::markfeed::PushConsumer *&()' over `NO::orion::markfeed::PushConsumer_var::operator NO::orion::markfeed::PushConsumer *const &() const' SerialServant.cpp:36: warning: for conversion from `NO::orion::markfeed::PushConsumer_var' to `CORBA_Object *' SerialServant.cpp:36: warning: because conversion sequence for the argument is better SerialServant.cpp: In method `class NO::orion::markfeed::PushConsumer * NO::orion::markfeed::SerialServant::admin_interface()': SerialServant.cpp:41: warning: choosing `NO::orion::markfeed::PushConsumer_var::operator NO::orion::markfeed::PushConsumer *&()' over `NO::orion::markfeed::PushConsumer_var::operator NO::orion::markfeed::PushConsumer *const &() const' SerialServant.cpp:41: warning: for conversion from `NO::orion::markfeed::PushConsumer_var' to `NO::orion::markfeed::PushConsumer *' SerialServant.cpp:41: warning: because conversion sequence for the argument is better SerialServant.cpp: In method `class NO::orion::markfeed::Feed * NO::orion::markfeed::SerialServant::peer()': SerialServant.cpp:90: warning: choosing `NO::orion::markfeed::Feed_var::operator NO::orion::markfeed::Feed *&()' over `NO::orion::markfeed::Feed_var::operator NO::orion::markfeed::Feed *const &() const' SerialServant.cpp:90: warning: for conversion from `NO::orion::markfeed::Feed_var' to `NO::orion::markfeed::Feed *' SerialServant.cpp:90: warning: because conversion sequence for the argument is better SerialServant.cpp: In method `void NO::orion::markfeed::SerialServant::dump_config()': SerialServant.cpp:186: warning: choosing `NO::orion::markfeed::Feed_var::operator NO::orion::markfeed::Feed *&()' over `NO::orion::markfeed::Feed_var::operator NO::orion::markfeed::Feed *const &() const' SerialServant.cpp:186: warning: for conversion from `NO::orion::markfeed::Feed_var' to `CORBA_Object *' SerialServant.cpp:186: warning: because conversion sequence for the argument is better SerialServant.cpp: In method `void NO::orion::markfeed::SerialServant::notify(const char *)': SerialServant.cpp:193: warning: choosing `NO::orion::markfeed::PushConsumer_var::operator NO::orion::markfeed::PushConsumer *&()' over `NO::orion::markfeed::PushConsumer_var::operator NO::orion::markfeed::PushConsumer *const &() const' SerialServant.cpp:193: warning: for conversion from `NO::orion::markfeed::PushConsumer_var' to `CORBA_Object *' SerialServant.cpp:193: warning: because conversion sequence for the argument is better SerialServant.cpp:194: warning: choosing `NO::orion::markfeed::PushConsumer_var::operator NO::orion::markfeed::PushConsumer *&()' over `NO::orion::markfeed::PushConsumer_var::operator NO::orion::markfeed::PushConsumer *const &() const' SerialServant.cpp:194: warning: for conversion from `NO::orion::markfeed::PushConsumer_var' to `CORBA_Object *' SerialServant.cpp:194: warning: because conversion sequence for the argument is better SerialServant.cpp: In method `void NO::orion::markfeed::SerialServant::stop()': SerialServant.cpp:204: warning: choosing `PortableServer::_tao_seq_Octet_var::operator PortableServer::_tao_seq_Octet &()' over `PortableServer::_tao_seq_Octet_var::operator const PortableServer::_tao_seq_Octet &() const' SerialServant.cpp:204: warning: for conversion from `PortableServer::ObjectId_var' to `const PortableServer::ObjectId &' SerialServant.cpp:204: warning: because conversion sequence for the argument is better SerialServant.cpp: In method `NO::orion::markfeed::SerialServant::SerialServant(const string &, const string &, unsigned int, NO::orion::markfeed::Feed *, bool, NO::orion::markfeed::RunState)': SerialServant.cpp:297: warning: choosing `NO::orion::markfeed::Feed_var::operator NO::orion::markfeed::Feed *&()' over `NO::orion::markfeed::Feed_var::operator NO::orion::markfeed::Feed *const &() const' SerialServant.cpp:297: warning: for conversion from `NO::orion::markfeed::Feed_var' to `CORBA_Object *' SerialServant.cpp:297: warning: because conversion sequence for the argument is better SerialServant.cpp:301: warning: choosing `PortableServer::_tao_seq_Octet_var::operator PortableServer::_tao_seq_Octet &()' over `PortableServer::_tao_seq_Octet_var::operator const PortableServer::_tao_seq_Octet &() const' SerialServant.cpp:301: warning: for conversion from `PortableServer::ObjectId_var' to `const PortableServer::ObjectId &' SerialServant.cpp:301: warning: because conversion sequence for the argument is better SerialServant.cpp:324: warning: choosing `CORBA_String_var::operator char *()' over `CORBA_String_var::operator const char *() const' SerialServant.cpp:324: warning: for conversion from `CORBA::String_var' to `const char *' SerialServant.cpp:324: warning: because conversion sequence for the argument is better SerialServant.cpp: In method `bool NO::orion::markfeed::SerialServant::Connected::process_line(const string &)': SerialServant.cpp:977: warning: choosing `CORBA_String_var::operator char *()' over `CORBA_String_var::operator const char *() const' SerialServant.cpp:977: warning: for conversion from `CORBA::String_var' to `const char *' SerialServant.cpp:977: warning: because conversion sequence for the argument is better /usr/local/i686-pc-linux-gnu/bin/as -V -Qy -o SerialServant.o SerialServant.s GNU assembler version 2.9.1 (i686-pc-linux-gnu), using BFD version 2.9.1.0.19 Compilation finished at Thu Aug 26 12:29:54