Parse error on assigning a std::pair

SonarQube 9.3 (build 51899), CFamily Code Quality and Security 6.30.0.42324 (cpp)
Visual Studio 2019, Version 16.9.6

SonarQube reports a parse error when assigning a std::pair, even a benign one like std::pair<int,int>.
Example:

std::pair<int, int> P:
P = std::pair<int, int>();	

Error message: “no viable overloaded ‘=’”

Parse error is also present if a custom struct that contains a std::pair uses its assignment operator.

Hello @mpt,

I tried to recreate the issue you described, but it did not produce any parse error.

In order to better understand the situation, could you please create a small test program that triggers the parse error, then generate a reproducer for it?

To generate the reproducer file:

  • Search in the analysis log for the full path of the source file for which you want to create a reproducer (for instance, here, the file that generates this issue). You will have to use exactly this name (same case, / or \…)
  • Add the reproducer option to the scanner configuration:
    sonar.cfamily.reproducer= "Full path to the source file"
  • Re-run the scanner to generate a file named sonar-cfamily.reproducer in the project folder.
  • Please share this file.

Thank you!

Hi @JolyLoic,

thanks for taking a look at this. I can repro this with a minimal example. Attached is the requested reproducer file.
sonar-cfamily.reproducer (750.3 KB)

Thank you, @mpt, for raising the reproducer. I could reproduce it and it lead to the creation of this ticket: CPP-3648.

FYI, we fixed the issue and it should be available in the next release.

In the meantime, to work around the issue, you can add the following to the build command used for analysis: /D"__is_assignable_no_precondition_check=__is_assignable".

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.