Bug 303647 - DU chain resolves pointer to member incorrectly
Summary: DU chain resolves pointer to member incorrectly
Status: CONFIRMED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (other bugs)
Version First Reported In: 4.3.1
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-17 08:19 UTC by Gerhard
Modified: 2016-09-08 20:05 UTC (History)
1 user (show)

See Also:
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 (38.56 KB, image/png)
2012-07-17 08:20 UTC, Gerhard
Details
popup that is shown hovering over the pointer to member (34.93 KB, image/png)
2012-07-17 08:21 UTC, Gerhard
Details

Note You need to log in before you can comment on or make changes to this bug.
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.