Skip to content

fno-char8_t argument is ignored from compile commands #12968

Closed

Description

Environment

  • OS and Version: W11 22631.4460
  • VS Code Version: 1.95.1
  • C/C++ Extension Version: 1.23.1

Bug Summary and Steps to Reproduce

Bug Summary:
An option exists on clang (there is an equivalent on msvc with /Zc:char8_t-) removing the char8_t type from the language in C++20. It is controlled in clang by the -fno-char8_t argument.
When using compile commands, with this argument and --std=c++20 present in the command, the parsing seems to ignore the -fno-char8_t, leading to Intellisense errors.

When looking for duplicates, I found #12106, but given the explanation, it seems that every argument is parsed, even if not needed so it doesn't related to this issue.

Steps to reproduce:

  1. create a file containing the code below:
#include <stdio.h>

int main(int argc, char** argv)
{
	printf(u8"Hello UTF-8");

	return 0;
}
  1. create a compile commands containing the source with both -fno-char8_t and --std=c++20 in the command, as below:
[
	{
		"directory": "src",
		"command": "clang++ -g -Wall -fno-char8_t --std=c++20",
		"file": "test.cc"
	}
]
  1. Notice the errors displaying on u8, indicating that argument const char8_t* is incompatible with const char*

Expected behavior:
The parsing should take account of the -fno-char8_t to give it correctly to the parser. On a side note, the argument is not given either to clang-tidy, leading to other errors related to it.

Configuration and Logs

-------- Diagnostics - 11/15/2024, 11:10:57 PM
Version: 1.23.1
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "c:/Dev/Sources/C++ tests/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "cStandard": "c17",
    "intelliSenseMode": "windows-clang-x64",
    "compileCommands": "c:\\Dev\\Sources\\C++ tests/compile_commands.json",
    "compilerPathIsExplicit": false,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compileCommandsInCppPropertiesJson": "${workspaceFolder}/compile_commands.json",
    "cppStandard": "c++17",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "c:/Dev/Sources/C++ tests/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.default.compilerPath": "C:\\Dev\\LLVM\\bin\\clang.exe",
    "C_Cpp.default.cppStandard": "c++17",
    "C_Cpp.exclusionPolicy": "checkFilesAndFolders",
    "C_Cpp.formatting": "clangFormat",
    "C_Cpp.doxygen.generateOnType": false,
    "C_Cpp.codeAnalysis.exclude": {
        "folder": true
    },
    "C_Cpp.codeAnalysis.clangTidy.enabled": true,
    "C_Cpp.codeAnalysis.clangTidy.path": "C:\\Dev\\LLVM\\bin\\clang-tidy.exe",
    "C_Cpp.intelliSenseMemoryLimit": 16384,
    "C_Cpp.loggingLevel": "Debug",
    "C_Cpp.experimentalFeatures": "enabled"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": false,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "*.sln": "xml",
        "log": "log"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.23.1.0
Current database path: C:\USERS\AUBIN\APPDATA\LOCAL\MICROSOFT\VSCODE-CPPTOOLS\2E0838E3C682A3A1661B48151AF947FF\.BROWSE.VC.DB
Translation Unit Mappings:
[ C:\Dev\Sources\C++ tests\src\test.cc - source TU]:
Translation Unit Configurations:
[ C:\Dev\Sources\C++ tests\src\test.cc ]
    Process ID: 17732
    Memory Usage: 64 MB
    Compiler Path: C:\Dev\LLVM\bin\clang++.exe
    Includes:
    System Includes:
        C:\Dev\LLVM\lib\clang\18\include
        C:\Dev\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include
        C:\Dev\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\atlmfc\include
        C:\Windows Kits\10\Include\10.0.22621.0\ucrt
        C:\Windows Kits\10\Include\10.0.22621.0\shared
        C:\Windows Kits\10\Include\10.0.22621.0\um
        C:\Windows Kits\10\Include\10.0.22621.0\winrt
        C:\Windows Kits\10\Include\10.0.22621.0\cppwinrt
    Standard Version: c++20
    IntelliSense Mode: windows-clang-x64
    Other Flags:
        --clang
        --clang_version=180108
        --ms_compatibility
    compile_commands.json entry:
        directory: c:\Dev\Sources\C++ tests/src
        file: c:\Dev\Sources\C++ tests/src/test.cc
        command: clang++ -g -Wall -fno-char8_t --std=c++20
Total Memory Usage: 64 MB
Browse Paths from compile_commands.json, from workspace folder: C:\Dev\Sources\C++ tests
    C:\Dev\Sources\C++ tests\src

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 5383

Other Extensions

No response

Additional context

No response

Activity

  1. moved this from Pull Request to Done in cpptoolson Nov 18, 2024
  2. sean-mcmanus commented on Dec 6, 2024

    @sean-mcmanus
    Contributor
  3. locked and limited conversation to collaborators on Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions