Bug 261306 - 'Jump to definition/declaration' works incorrectly in case of name collision
Summary: 'Jump to definition/declaration' works incorrectly in case of name collision
Status: RESOLVED WORKSFORME
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: 4.1.60
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: 4.2.0
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-26 19:05 UTC by Alexey Chernov
Modified: 2010-12-30 01:35 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Header to reproduce (3.97 KB, text/plain)
2010-12-26 20:05 UTC, Alexey Chernov
Details
Source to reproduce (34.20 KB, text/plain)
2010-12-26 20:05 UTC, Alexey Chernov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Chernov 2010-12-26 19:05:22 UTC
Version:           4.1.60 (using KDE 4.5.4) 
OS:                Linux

'Jump to definition' and 'Jump to declaration' options work incorrectly in case of matching of the names of functions. For instance, consider the following code:

//foo.h
namespace
{
  class A
  {
    int read(int a, int b);
    void foo();
  }
}

//foo.cpp
#include "foo.h"

using namespace std;

void A::foo()
{
  read(0, 0);
}

int A::read(int a, int b)
{
}

It is very simplified version of my code to reproduce, so maybe any other headers would be needed to include to reproduce fully. The result is:
- the compiler correctly solves the name conflict using read() method of class as it has bigger priority
- when using 'jump to definition' or 'jump to declaration' options KDevelop opens unistd.h (on Linux) header and read() function in it which is obviously not correct in terms of compilation algorithm.

Reproducible: Always
Comment 1 Milian Wolff 2010-12-26 19:40:06 UTC
works for me, you are missing a semicolon after class A { ... } in the header.
Comment 2 Alexey Chernov 2010-12-26 20:04:10 UTC
OK, let's see at the whole sources then. Two file are attached. To reproduce:
1. Create empty project (I used CMake non-GUI project)
2. Add these two files to it. Don't try to compile as it won't.
3. Go to line #456 in foo.cpp, set cursor to 'read' call and use either Jump to declaration or Jump to definition.
4. See that it jumped to unistd.h instead of the same foo.cpp source where read method is defined.

Perhaps it depends on architecture, mine is x86_64. I also can confirm that the compiler really calls read() method and not a function from unistd.h.
Comment 3 Alexey Chernov 2010-12-26 20:05:12 UTC
Created attachment 55264 [details]
Header to reproduce
Comment 4 Alexey Chernov 2010-12-26 20:05:38 UTC
Created attachment 55265 [details]
Source to reproduce
Comment 5 Milian Wolff 2010-12-27 22:03:28 UTC
Please strip these testcases down until you can still reproduce it. I doubt all those includes and functions are required, are they? Or at least upload the tarball of the project you created and make sure no missing files are tried to be included or such stuff.
Comment 6 Alexey Chernov 2010-12-27 22:52:08 UTC
No, I don't think they're all required. Thank you, I'll prepare proper test case without any trash. I just wanted to prevent the bug to be closed as it reproducible though in some subtle circumstances.
Comment 7 Alexey Chernov 2010-12-30 01:35:45 UTC
Well, during work on the bug related code I found I can't reproduce the bug anymore neither with testcase nor with the whole my project so I think it's some temporary fault. Clean - Build seem to fix the problem.