Bug 347527 - Undefined symbol is not marked as unresolved
Summary: Undefined symbol is not marked as unresolved
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-27 17:45 EDT by Sergey Prigogin CLA
Modified: 2020-09-04 15:18 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Prigogin CLA 2011-05-27 17:45:55 EDT
In the following code

void f(int* p);

void test() {
  f(&x); // Problem on F but no problem on x
}

the undefined symbol x is not marked as unresolved.
Comment 1 Markus Schorn CLA 2011-05-30 03:28:13 EDT
This is an interesting issue. Let me simplify your example first:

void f(int* p); 
void test() {
  f(x); 
}

In the example the parser has to decide whether the statement 'f(x)' is a declaration- or expression statement. It chooses the declaration statement, because it causes only one problem binding. 

You can make the code compile by changing the declaration of 'f':
typedef int f;
void test() {
  f(&x); 
}

To fix the issue, we'd have to put weights on the problem bindings found during ambiguity resolution. Vaguely there could be rules like that:
* A problem binding nested more deeply is less important
* A failure in the overload-resolution is less important than a failure in the 
  name-lookup

I am not sure whether this is worth the effort, though. 
However, this code is not correct, because the reference is not initialized. We could improve the parser to detect that. But then I can change the example to 

void f(int* p); // compiles with 'typedef int f', instead;
void test() {
  f(x); 
}
Comment 2 Sergey Prigogin CLA 2011-05-30 21:37:32 EDT
(In reply to comment #1)
> To fix the issue, we'd have to put weights on the problem bindings found during
> ambiguity resolution. Vaguely there could be rules like that:
> * A problem binding nested more deeply is less important
> * A failure in the overload-resolution is less important than a failure in the 
>   name-lookup

The minimal number of problem bindings as a target function for ambiguity resolution has always bothered me as something not based on the C++ spec. A more correct approach would be to prefer the code interpretation that pushes the first problem as further down as possible (in declaredBefore sense). The problems that cannot be ordered by declaredBefore could be classified into original and dependent. Dependent problems should not be counted towards the target function for ambiguity resolution.

The latter rule may be hard to implement, so we may have to replace it with the rules you proposed.

> I am not sure whether this is worth the effort, though. 

It may not be critical now, but will become more and more important as we improve Codan diagnostics and quick fixes.
Comment 3 Sergey Prigogin CLA 2014-03-26 13:47:51 EDT
See also related bug 431271.