There is a red wavy line but there is no error. Bug or settings?

zzzhhh 40 Reputation points
2024-06-16T06:08:44.82+00:00
void ff(int* p) { std::cout<< *p; };
void ff(unsigned int i) { i++; }
void func(void (&&fp)(int*)) { int i = 6; fp(&i); }	//no other overloaded versions of func
......
func(ff);


I compiled with no error or warning, but there is a wavy line indicating an error when calling func(ff);:

User's image

I don't like it because I expect Visual Studio IDE should not display the wavy line when there is no error. Is this a bug so there is no hope to fix it, or is there any settings of VS that can turn off the red wavy line when there is no error?

I am using Visual Studio 2019 Version 16.11.36 on Windows 10. Thanks.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,851 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,624 questions
{count} votes

3 answers

Sort by: Most helpful
  1. RLWA32 42,796 Reputation points
    2024-06-16T08:52:08.86+00:00

    I cut and pasted the posted code into a minimal VS2019 console application . There were no Intellisense errors in the display and no errors when building -

    fptest

    Have you tried right clicking the project node in solution explorer and selecting "Rescan Solution"? If you hover the mouse over the red squiggles is an error displayed?

    Another place to look is in the Error List when set to display Build+Intellisense messages.

    1 person found this answer helpful.
    0 comments No comments

  2. Anna Xiu-MSFT 27,721 Reputation points Microsoft Vendor
    2024-06-17T06:24:15.13+00:00

    Hi @zzzhhh

    Welcome to Microsoft Q&A! 

    Please close all running VS instances and manually delete the hidden .vs, bin and obj folders in the project folder.

    Then, clean and rebuild the solution. 

    If you have any third-party extensions installed, please disable or uninstall the installed extensions under Extensions > Manage Extensions > Installed

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. zzzhhh 40 Reputation points
    2024-06-18T04:32:32.19+00:00

    My bad. There is another func function hidden far away in the source file that caused the overloading issue.

    How nice it would be if there is a brown color on the margin of VS IDE that marks all the overloaded functions when I click the func call.

    0 comments No comments