Bug 303647

Summary: DU chain resolves pointer to member incorrectly
Product: [Applications] kdevelop Reporter: Gerhard <gstengel>
Component: Language Support: CPP (old)Assignee: kdevelop-bugs-null
Status: CONFIRMED ---    
Severity: normal CC: intelfx
Priority: NOR    
Version First Reported In: 4.3.1   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: popup that is shown for a function having a pointer to member as function argument
popup that is shown hovering over the pointer to member

Description Gerhard 2012-07-17 08:19:00 UTC
If I pass a pointer to member as a function argument, the DU chain shows an erroneous function signature, see attached screenshot 

Reproducible: Always

Steps to Reproduce:
1. open the small sample code I attached in "Additional Information"
2. Hover with the mouse over the function configure_p2m 
3. look at the popup showing the function signature
Actual Results:  
The function signature seems to have 2 arguments instead of one:
void configure_p2m(function int PointerToMemberTest::*()const , int PointerToMemberTest::* get_ptr)

Expected Results:  
it should show:
void configure_p2m(int (PointerToMemberTest::*get_ptr)() const);

even when hovering over the pointer to member itself, the contents of the popup is questionable:
int PointerToMemberTest::* PointerToMemberTest()
Looks like a constructor with the return value int PointerToMemberTest::*  ....


#include <iostream>

class PointerToMemberTest
{
public:
   int (PointerToMemberTest::*d_pget)() const;
   void configure_p2m(int (PointerToMemberTest::*get_ptr)() const);
   PointerToMemberTest(int init_val);
   int get_single() const;
   int get_double() const;
   int get() const;
private:
   int d_value;
};

int PointerToMemberTest::get_single() const
{
   return d_value;
}

int PointerToMemberTest::get_double() const
{
   return d_value * 2;
}

int PointerToMemberTest::get() const
{
   return (this->*d_pget)();
}

PointerToMemberTest::PointerToMemberTest(int init_val)
: d_value(init_val)
{
}

void PointerToMemberTest::configure_p2m(int (PointerToMemberTest::*get_ptr)() const)
{
   d_pget = get_ptr;
}

int main(int argc, char **argv)
{
   PointerToMemberTest p2mtest(5);
//   p2mtest.configure_p2m(&PointerToMemberTest::get_double);
   p2mtest.configure_p2m(&PointerToMemberTest::get_single);
   std::cout << "Return value of getter: " << p2mtest.get() << std::endl;
}
Comment 1 Gerhard 2012-07-17 08:20:54 UTC
Created attachment 72574 [details]
popup that is shown for a function having a pointer to member as function argument
Comment 2 Gerhard 2012-07-17 08:21:35 UTC
Created attachment 72575 [details]
popup that is shown hovering over the pointer to member
Comment 3 Ivan Shapovalov 2012-07-17 13:23:59 UTC
This is a known bug... Well, C++ parser is currently unable to handle pointers to functions of any type. They do not trigger parsing errors, but are handled incorrectly.
Comment 4 Kevin Funk 2016-09-08 20:05:28 UTC
Still a problem in KDevelop 5.0, the function sig in the popup makes no sense.