public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/52888] New: Unable to inline function pointer call with inexact signature match
@ 2012-04-06 16:09 msharov at users dot sourceforge.net
  2012-04-10 11:49 ` [Bug rtl-optimization/52888] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: msharov at users dot sourceforge.net @ 2012-04-06 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52888
           Summary: Unable to inline function pointer call with inexact
                    signature match
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: msharov@users.sourceforge.net


#include <stdio.h>

struct A {
    template <typename T>
    static inline __attribute__((always_inline))
    void Caller (T* pn, void (T::*pm)(void))
        { (pn->*pm)(); }

    void Call (int i) {
        if (i == 1) Caller(this, &A::Func1);
        else if (i == 2) Caller(this, &A::Func2);
    }
    inline void Func1 (void)            { puts ("Func1"); }
    inline void Func2 (void) noexcept   { puts ("Func2"); }
};

int main (void) { A a; a.Call(1); a.Call(2); return (0); }
-------------------------------------------------------------
Compiling with: g++ (GCC) 4.7.0 20120324 (prerelease), x86_64
> g++ -O -std=c++11 a.cc
a.cc: In function 'int main()':
a.cc:5:55: error: inlining failed in call to always_inline 'static void
A::Caller(T*, void (T::*)()) [with T = A]': mismatched arguments
a.cc:10:42: error: called from here
a.cc:5:55: error: inlining failed in call to always_inline 'static void
A::Caller(T*, void (T::*)()) [with T = A]': mismatched arguments
a.cc:10:42: error: called from here
-------------------------------------------------------------
I'm using always_inline to force the error; without it Caller is not inlined
errorlessly.

The problem occurs when the function pointer has an inexact signature match to
the pointed function. In the above example, Func2 has a noexcept tacked on to
it. In more complex examples involving pointer to function with arguments,
using a typedef of an object in argument list results in this error, while
using the actual object works (typedef A a_t; void good(A&); void bad(a_t&)).
So the compiler is able to explicitly convert an inexact match like &A::Func2
to void(A::*)(void) when instantiating the template, but the inliner is not
able to make the same match even though it should have the same information.


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

* [Bug rtl-optimization/52888] Unable to inline function pointer call with inexact signature match
  2012-04-06 16:09 [Bug rtl-optimization/52888] New: Unable to inline function pointer call with inexact signature match msharov at users dot sourceforge.net
@ 2012-04-10 11:49 ` rguenth at gcc dot gnu.org
  2012-04-10 13:21 ` [Bug middle-end/52888] " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-04-10 11:49 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-04-10
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-04-10 11:49:14 UTC ---
It's the pointer-to-member function descriptor that is rejected.  The
compatibility check is too constrained, I have a fix (for this particular case
at least).


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

* [Bug middle-end/52888] Unable to inline function pointer call with inexact signature match
  2012-04-06 16:09 [Bug rtl-optimization/52888] New: Unable to inline function pointer call with inexact signature match msharov at users dot sourceforge.net
  2012-04-10 11:49 ` [Bug rtl-optimization/52888] " rguenth at gcc dot gnu.org
@ 2012-04-10 13:21 ` rguenth at gcc dot gnu.org
  2012-04-10 13:22 ` [Bug rtl-optimization/52888] " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-04-10 13:21 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
          Component|rtl-optimization            |middle-end
         Resolution|                            |FIXED
   Target Milestone|---                         |4.8.0

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-04-10 13:21:11 UTC ---
Fixed for trunk.


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

* [Bug rtl-optimization/52888] Unable to inline function pointer call with inexact signature match
  2012-04-06 16:09 [Bug rtl-optimization/52888] New: Unable to inline function pointer call with inexact signature match msharov at users dot sourceforge.net
  2012-04-10 11:49 ` [Bug rtl-optimization/52888] " rguenth at gcc dot gnu.org
  2012-04-10 13:21 ` [Bug middle-end/52888] " rguenth at gcc dot gnu.org
@ 2012-04-10 13:22 ` rguenth at gcc dot gnu.org
  2013-03-01 11:08 ` [Bug middle-end/52888] " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-04-10 13:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-04-10 13:20:55 UTC ---
Author: rguenth
Date: Tue Apr 10 13:20:50 2012
New Revision: 186276

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186276
Log:
2012-04-10  Richard Guenther  <rguenther@suse.de>

    PR middle-end/52888
    * gimple-low.c (gimple_check_call_args): Properly account for
    compatible aggregate types.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimple-low.c


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

* [Bug middle-end/52888] Unable to inline function pointer call with inexact signature match
  2012-04-06 16:09 [Bug rtl-optimization/52888] New: Unable to inline function pointer call with inexact signature match msharov at users dot sourceforge.net
                   ` (2 preceding siblings ...)
  2012-04-10 13:22 ` [Bug rtl-optimization/52888] " rguenth at gcc dot gnu.org
@ 2013-03-01 11:08 ` rguenth at gcc dot gnu.org
  2013-03-01 12:46 ` rguenth at gcc dot gnu.org
  2013-03-01 13:10 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-01 11:08 UTC (permalink / raw)
  To: gcc-bugs


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |geza at bitquad dot com

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-01 11:08:02 UTC ---
*** Bug 55788 has been marked as a duplicate of this bug. ***


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

* [Bug middle-end/52888] Unable to inline function pointer call with inexact signature match
  2012-04-06 16:09 [Bug rtl-optimization/52888] New: Unable to inline function pointer call with inexact signature match msharov at users dot sourceforge.net
                   ` (3 preceding siblings ...)
  2013-03-01 11:08 ` [Bug middle-end/52888] " rguenth at gcc dot gnu.org
@ 2013-03-01 12:46 ` rguenth at gcc dot gnu.org
  2013-03-01 13:10 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-01 12:46 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-01 12:46:17 UTC ---
Author: rguenth
Date: Fri Mar  1 12:46:12 2013
New Revision: 196378

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196378
Log:
2013-03-01  Richard Biener  <rguenther@suse.de>

    Backport from mainline
    2012-04-10  Richard Guenther  <rguenther@suse.de>

    PR middle-end/52888
    * gimple-low.c (gimple_check_call_args): Properly account for
    compatible aggregate types.

Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/gimple-low.c


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

* [Bug middle-end/52888] Unable to inline function pointer call with inexact signature match
  2012-04-06 16:09 [Bug rtl-optimization/52888] New: Unable to inline function pointer call with inexact signature match msharov at users dot sourceforge.net
                   ` (4 preceding siblings ...)
  2013-03-01 12:46 ` rguenth at gcc dot gnu.org
@ 2013-03-01 13:10 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-01 13:10 UTC (permalink / raw)
  To: gcc-bugs


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.7.3, 4.8.0
   Target Milestone|4.8.0                       |4.7.3
      Known to fail|                            |4.7.2

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-01 13:09:58 UTC ---
Fixed for 4.7.3, too.


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

end of thread, other threads:[~2013-03-01 13:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-06 16:09 [Bug rtl-optimization/52888] New: Unable to inline function pointer call with inexact signature match msharov at users dot sourceforge.net
2012-04-10 11:49 ` [Bug rtl-optimization/52888] " rguenth at gcc dot gnu.org
2012-04-10 13:21 ` [Bug middle-end/52888] " rguenth at gcc dot gnu.org
2012-04-10 13:22 ` [Bug rtl-optimization/52888] " rguenth at gcc dot gnu.org
2013-03-01 11:08 ` [Bug middle-end/52888] " rguenth at gcc dot gnu.org
2013-03-01 12:46 ` rguenth at gcc dot gnu.org
2013-03-01 13:10 ` rguenth at gcc dot gnu.org

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