public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/45880] New: Template-Methode in Shared Object not resolved when compiled with -O2
@ 2010-10-04 13:59 r.menges at nice2cu dot de
  2010-10-04 14:22 ` [Bug c++/45880] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: r.menges at nice2cu dot de @ 2010-10-04 13:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45880

           Summary: Template-Methode in Shared Object not resolved when
                    compiled with -O2
           Product: gcc
           Version: 4.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: r.menges@nice2cu.de


Compiling the application with -O2 crashes the application because of a
symbol-not-defined-error, while compiling without -O2 Option or using -g 
works.

Actually I am overloading and not specializing an template-methode, which is
propabily not the right way, but the example is trivial and because the
application crashes when compiled with -O2 and not when compiled with -g or
without the -O2 option i decided to send this bugreport.

System is 
uname -a
Linux dev 2.6.31-gentoo-r10 #1 SMP Mon Mar 8 21:00:17 CET 2010 i686 AMD
Athlon(tm) XP 3000+ AuthenticAMD GNU/Linux
and
g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.3.4/work/gcc-4.3.4/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.3.4
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.4/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--disable-fixed-point --enable-nls --without-included-gettext
--with-system-zlib --disable-checking --disable-werror --enable-secureplt
--disable-multilib --enable-libmudflap --disable-libssp --disable-libgomp
--with-arch=i686 --enable-languages=c,c++,java,treelang --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.4 p1.1,
pie-10.1.5'
Thread model: posix
gcc version 4.3.4 (Gentoo 4.3.4 p1.1, pie-10.1.5)

The tarBall contains the minimal-exmaple (source of shared libary and
executable), compiler output and short description


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

* [Bug c++/45880] Template-Methode in Shared Object not resolved when compiled with -O2
  2010-10-04 13:59 [Bug c++/45880] New: Template-Methode in Shared Object not resolved when compiled with -O2 r.menges at nice2cu dot de
@ 2010-10-04 14:22 ` redi at gcc dot gnu.org
  2010-10-04 14:49 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2010-10-04 14:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45880

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-10-04 14:21:57 UTC ---
why are you using -shared to produce your executable?


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

* [Bug c++/45880] Template-Methode in Shared Object not resolved when compiled with -O2
  2010-10-04 13:59 [Bug c++/45880] New: Template-Methode in Shared Object not resolved when compiled with -O2 r.menges at nice2cu dot de
  2010-10-04 14:22 ` [Bug c++/45880] " redi at gcc dot gnu.org
@ 2010-10-04 14:49 ` redi at gcc dot gnu.org
  2010-10-04 16:14 ` r.menges at nice2cu dot de
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2010-10-04 14:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45880

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-10-04 14:48:51 UTC ---
Please also show the error you're getting, as "crashes the application because
of a symbol-not-defined-error" is not very helpful

I don't think this has anything to do with using a template function, I think
you've just built it wrong


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

* [Bug c++/45880] Template-Methode in Shared Object not resolved when compiled with -O2
  2010-10-04 13:59 [Bug c++/45880] New: Template-Methode in Shared Object not resolved when compiled with -O2 r.menges at nice2cu dot de
  2010-10-04 14:22 ` [Bug c++/45880] " redi at gcc dot gnu.org
  2010-10-04 14:49 ` redi at gcc dot gnu.org
@ 2010-10-04 16:14 ` r.menges at nice2cu dot de
  2010-10-04 16:34 ` redi at gcc dot gnu.org
  2011-09-25 15:59 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: r.menges at nice2cu dot de @ 2010-10-04 16:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45880

--- Comment #4 from r.menges at nice2cu dot de 2010-10-04 16:14:34 UTC ---
(In reply to comment #3)
> Please also show the error you're getting, as "crashes the application because
> of a symbol-not-defined-error" is not very helpful
> 
> I don't think this has anything to do with using a template function, I think
> you've just built it wrong

Actually i didn't write the makefile myself, it was generated by netbeans
(6.7.).
I am sorry, i was inexact about the error message: The symbol-not-defined
is the error i see when using the original-code, which is executed in an apache
context. The example simply crashes with an segfault.

But you are right, the option -share is what caused the segfault in this
example.
After i removed the -shared option manually from the generated makefile, the
example crashes no more.

The "real" applications runs as an extension to php5 in the context of apache,
it's an libary for c++-php-bridge we builded (so that c++-objects can be mapped
into the space of php). This is where undefined symbol errors crashes the
httpd-process with an error of undefined symbol, when using 

template<typename MsgType> void printMessage(MsgType msg);
void printMessage(const char *);

it misses the implemetation for std::string.


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

* [Bug c++/45880] Template-Methode in Shared Object not resolved when compiled with -O2
  2010-10-04 13:59 [Bug c++/45880] New: Template-Methode in Shared Object not resolved when compiled with -O2 r.menges at nice2cu dot de
                   ` (2 preceding siblings ...)
  2010-10-04 16:14 ` r.menges at nice2cu dot de
@ 2010-10-04 16:34 ` redi at gcc dot gnu.org
  2011-09-25 15:59 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2010-10-04 16:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45880

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-10-04 16:34:21 UTC ---
We need a self-contained testcase that reproduces the problem.

I suspect you just need an explicit instantiation of that template function in
the shared library, if nothing instantiates it explicitly then the symbol won't
be defined.

For your broken minimal example that would be done like this:

template void TestTemplateOpt::printMessage(std::string);


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

* [Bug c++/45880] Template-Methode in Shared Object not resolved when compiled with -O2
  2010-10-04 13:59 [Bug c++/45880] New: Template-Methode in Shared Object not resolved when compiled with -O2 r.menges at nice2cu dot de
                   ` (3 preceding siblings ...)
  2010-10-04 16:34 ` redi at gcc dot gnu.org
@ 2011-09-25 15:59 ` paolo.carlini at oracle dot com
  4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-25 15:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45880

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-25 15:45:24 UTC ---
Feedback not forthcoming.


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

end of thread, other threads:[~2011-09-25 15:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-04 13:59 [Bug c++/45880] New: Template-Methode in Shared Object not resolved when compiled with -O2 r.menges at nice2cu dot de
2010-10-04 14:22 ` [Bug c++/45880] " redi at gcc dot gnu.org
2010-10-04 14:49 ` redi at gcc dot gnu.org
2010-10-04 16:14 ` r.menges at nice2cu dot de
2010-10-04 16:34 ` redi at gcc dot gnu.org
2011-09-25 15:59 ` paolo.carlini at oracle dot com

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).