Scanner error in SonarQube 8.9 LTS when analyzing a C++20 module

Hi, we realize the support of the C++20 modules may still be experimental but we wanted to talk about this issue in case a solution could be found.

Environment:

  • SonarQube: Develop Edition 8.9.7.52159 (LTS) installed with a standard Docker image
  • No plugin installed
  • CFamily plugin version: 6.20.3.42796
  • Sonar scanner: installed on a Windows 10 amd64 agent used by GitLab
  • Steps to reproduce: analyze a directory containing C++20 modules, most of them cannot be processed successfully
  • Workaround: use sonar.exclusions to prevent them from being analyzed
  • Problem: we currently have to keep using the LTS version and cannot upgrade to the latest 9.4 version

Here is a snippet of the logs:

ERROR: Error during SonarScanner execution
java.lang.IllegalStateException:
An error occurred while analyzing the following compilation unit
foo.cpp
...
	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:399)
	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:175)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)

And we used the following command line to analyze our code:

dotnet dotnet-sonarscanner begin -k:"<key>" -d:sonar.login="$SONAR_TOKEN" -d:sonar.host.url="$SONAR_HOST_URL" -d:sonar.cfamily.build-wrapper-output="<out dir>" -d:sonar.cfamily.cpp20=true -d:sonar.cpp.std=c++20
build-wrapper-win-x86-64.exe --out-dir "<same out dir as the previous line>" MSBuild.exe xyz.sln -p:Configuration=Release -t:build
dotnet dotnet-sonarscanner end -d:sonar.login="$SONAR_TOKEN"

We have a dump file called sonar-cfamily-reproducer.zip that could be useful to you and we may share it with you privately if you need.

The most simple code that crashes the scanner is less than 50 lines long and contains (AFAIK) no complex inheritance or C++20 feature except for being inside a module.

Edit: I see that some bug fixes have been applied to the version 8.9.8 LTS (which we haven’t installed yet). Do you think it could solve our issues with those C++20 modules?

Edit 2: We will upgrade to the version 8.9.8 LTS and get back to you as soon as possible.

Hello @quantum_olivier,

We don’t support modules yet, even in our latest release.

Is the module-aware project you tried to analyze a test project, or was it some production-level code? I’m asking because knowing if our users actually use modules is important for define our roadmap.

Thanks for your answer. It is not a test and we decided to switch from C++11/14 to C++20 in our product since the compilers were available.

Do you know if modules will be supported soon or will it take more time? Anyway, I’ll mark your answer as the solution since we cannot do anything right now.

Hi @quantum_olivier,

Thank you for the information. Good to know that people are starting to really use modules!

Our tool is built on top of clang, and while this is great for many points, it also means that as long as clang does not provide good support for modules, it’s going to be hard for us to do so…

And even when modules becomes available in clang, it’s going to have some impact of the way we organize the analysis, so it will require time to be correctly supported.

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