Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352268 - A function with a reference parameter is not resolved when the parameter is a return value from another function
Summary: A function with a reference parameter is not resolved when the parameter is a...
Status: RESOLVED INVALID
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 8.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-16 07:44 EDT by Gil Barash CLA
Modified: 2011-07-20 03:07 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gil Barash CLA 2011-07-16 07:44:37 EDT
Build Identifier: Eclipse I20110613-1736 CDT 8.0

See steps to reproduce below...
(The code compiles and works fine under VC++ compiler)

Reproducible: Always

Steps to Reproduce:
Writing the following code causes "foo" to be unresolved:

class A
{
  int a;
};

int foo(A &p)
{
  return 0;
}

A get()
{
  return A();
}

int main() {
  foo(get()); // <- "foo" not resolved
  return 0;
}
Comment 1 Marc-André Laperle CLA 2011-07-17 15:13:34 EDT
Hmmm, it doesn't compile with gcc 4.5.2 ang clang 2.9 though.

error: invalid initialization of non-const reference of type 'A&' from an rvalue of type 'A'
error: in passing argument 1 of 'int foo(A&)'

If you use /Za (disable language extensions) in VS you should get
Error	2	error C2664: 'foo' : cannot convert parameter 1 from 'A' to 'A &'
Comment 2 Markus Schorn CLA 2011-07-20 03:07:42 EDT
This is invalid c++ code. Microsoft decided not to support this feature in the future, see
http://msdn.microsoft.com/en-us/library/s5b150wd(v=vs.71).aspx