Bug 577752 - Incorrectly detected "invalid arguments" with valid std::swap usage
Summary: Incorrectly detected "invalid arguments" with valid std::swap usage
Status: RESOLVED WONTFIX
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: 10.5.0   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-10 20:53 EST by Peter Barth CLA
Modified: 2024-05-15 10:56 EDT (History)
4 users (show)

See Also:


Attachments
ScreenShot Win10 mingw (100.87 KB, image/png)
2021-12-10 20:53 EST, Peter Barth CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Barth CLA 2021-12-10 20:53:39 EST
Created attachment 287663 [details]
ScreenShot Win10 mingw

In the following simple programm

```
#include <utility>
#include <iostream>
using namespace std;

int main() {
	int a=17, b=42;
	cout << "a=" << a << ", b=" << b << endl;
	swap(a, b);
	cout << "a=" << a << ", b=" << b << endl;
}
```

the line with swap is marked with "invalid arguments" and a horrible error message. 

```
Problem description: Invalid arguments ' Candidates are: std::enable_if::type 
 swap(#0 &, #0 &) std::enable_if::type swap(std::pair &, std::pair &) std::enable_if::
 type swap(#0 &, #0 &) std::enable_if::type swap(std::pair &, std::pair &) void 
 swap(std::__cxx11::basic_string &, std::__cxx11::basic_string &) std::enable_if::type 
 swap(#0 (&)[3 #1 0], #0 (&)[3 #1 0]) std::enable_if::type swap(#0 (&)[3 #1 0], #0 
 (&)[3 #1 0]) '
```

However, it compiles fine with any compiler I know of and any version of C++ in this millenium. Apparently, the indexer fails to parse the (admittedly horrid) implementation in the respective header of the standard libary?

This is on a clean install of eclipse 2021-12 on Windows 10 mit latest mingw, but also reproducible on linux (debian 11 + ubuntu 20.04). The project is a managed c++ project, no further configuration or options. Reindexing does not help.
Comment 1 David Crocker CLA 2024-01-31 04:52:48 EST
I frequently encounter this issue too. An example:

	FilamentMonitor *fm = nullptr;
	std::swap(fm, filamentSensors[p_driver]);

where FilamentMonitor is a declared class and filamentSensors is declared "static FilamentMonitor *filamentSensors[NumDrivers];".

I am using gcc arm-none-eabi version 12.2 with option -std=gnu++17.
Comment 2 Nathan Ridge CLA 2024-01-31 12:25:36 EST
(In reply to David Crocker from comment #1)
> I frequently encounter this issue too. An example:
> 
> 	FilamentMonitor *fm = nullptr;
> 	std::swap(fm, filamentSensors[p_driver]);
> 
> where FilamentMonitor is a declared class and filamentSensors is declared
> "static FilamentMonitor *filamentSensors[NumDrivers];".
> 
> I am using gcc arm-none-eabi version 12.2 with option -std=gnu++17.

You may have better luck trying the LSP integration mentioned at https://bugs.eclipse.org/bugs/show_bug.cgi?id=567764#c8 than waiting for this to be fixed
Comment 3 Peter Barth CLA 2024-05-15 00:49:29 EDT
2024-03 cdt and manually installing cdt-lsp stable -> my bugs disappear (both under linux and windows). Hopefully, cdt-lsp will be the default for cdt soon anyway. can be closed with "won't fix" as far as I'm concerned.
Comment 4 Jonah Graham CLA 2024-05-15 10:56:00 EDT
Thank you for reporting back your good experience.

The action plan is to include cdt-lsp in 2024-06 release and make it the default for new projects in CDT 12 as part of 2024-12 release.

Closing as wontfix for the existing CDT indexer.