public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/39140]  New: g++ doesn't inline vararg functions
@ 2009-02-09 16:02 thomas dot bleher at philosys dot de
  2009-02-09 16:42 ` [Bug c++/39140] " rguenth at gcc dot gnu dot org
  2009-02-10 12:53 ` thomas dot bleher at philosys dot de
  0 siblings, 2 replies; 3+ messages in thread
From: thomas dot bleher at philosys dot de @ 2009-02-09 16:02 UTC (permalink / raw)
  To: gcc-bugs

In the code below, g++ should eliminate both function calls when called with
-O2:
$ cat > inline_varargs.c <<END
inline void nonVararg( const char * dummy ) {}
inline void Vararg( const char * dummy, ... ) {}
int main()
{
    nonVararg("Hello");
    Vararg("World");
}
END

$ g++ -O2 inline_varargs.c

$ objdump -d a.out | c++filt | grep Vararg
 8048408:       e8 13 00 00 00          call   8048420 <Vararg(char const*,
...)>
08048420 <Vararg(char const*, ...)>:

$ gcc -O2 inline_varargs.c

$ objdump -d a.out | grep Vararg
08048350 <nonVararg>:
08048360 <Vararg>:

$ g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2
--program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --disable-libmudflap --enable-targets=all
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.2.4 20080512 (prerelease) (Debian 4.2.3-6)

As can be seen, gcc correclty inlines both functions, while g++ does not inline
the varargs function.

Trying to force inlining with __attribute__((always_inline)) leads to the
following error message:

inline_varargs.c: In function &#8216;int main()&#8217;:
inline_varargs.c:3: sorry, unimplemented: inlining failed in call to
&#8216;void Vararg(const char*, ...)&#8217;: function not inlinable
inline_varargs.c:7: sorry, unimplemented: called from here

This might be related to bug 10980, but as it works with gcc, I'm not sure what
the problem really is.


-- 
           Summary: g++ doesn't inline vararg functions
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thomas dot bleher at philosys dot de


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


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

* [Bug c++/39140] g++ doesn't inline vararg functions
  2009-02-09 16:02 [Bug c++/39140] New: g++ doesn't inline vararg functions thomas dot bleher at philosys dot de
@ 2009-02-09 16:42 ` rguenth at gcc dot gnu dot org
  2009-02-10 12:53 ` thomas dot bleher at philosys dot de
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-09 16:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-02-09 16:42 -------
Fixed since GCC 4.3.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

* [Bug c++/39140] g++ doesn't inline vararg functions
  2009-02-09 16:02 [Bug c++/39140] New: g++ doesn't inline vararg functions thomas dot bleher at philosys dot de
  2009-02-09 16:42 ` [Bug c++/39140] " rguenth at gcc dot gnu dot org
@ 2009-02-10 12:53 ` thomas dot bleher at philosys dot de
  1 sibling, 0 replies; 3+ messages in thread
From: thomas dot bleher at philosys dot de @ 2009-02-10 12:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from thomas dot bleher at philosys dot de  2009-02-10 12:53 -------
Thank you for the very fast response! Good to see that this is already fixed in
a newer GCC.


-- 


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


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

end of thread, other threads:[~2009-02-10 12:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-09 16:02 [Bug c++/39140] New: g++ doesn't inline vararg functions thomas dot bleher at philosys dot de
2009-02-09 16:42 ` [Bug c++/39140] " rguenth at gcc dot gnu dot org
2009-02-10 12:53 ` thomas dot bleher at philosys dot de

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