Skip to content

c++20 std::countl_zero highlight as error when using GCC with __builtins #13876

@Raffaello

Description

@Raffaello

Environment

  • OS and Version: Windows 11
  • VS Code Version: 1.103.2
  • C/C++ Extension Version: 1.26.3
  • If using SSH remote, specify OS of remote machine:

Bug Summary and Steps to Reproduce

Bug Summary:

#include <bit>
constexpr int bits = std::countl_zero<uint16_t>(0) - 1;

// intellisense reporting error:
// expression must have a constant valueC/C++(28)
// cannot call non-constexpr function "__builtin_clzg" (declared implicitly)

Steps to reproduce:

  1. create a file using a std:count_zero and assign to a constexpr
  2. compile it with gcc and c++20
  3. compilation is succesful
  4. intellisense should highlight an error as reported in the comments in the code snippet above

Expected behavior:

intellisense should not report an error

Configuration and Logs

- c_cpp_properties.json no file

log diagnostic:

-------- Diagnostics - 8/26/2025, 12:04:05 AM
Version: 1.26.3
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "c:/Users/myuser/source/repos/myrepo/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.26100.0",
    "compilerPath": "cl.exe",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-msvc-x64",
    "compilerPathInCppPropertiesJson": "cl.exe",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathIsExplicit": false,
    "configurationProvider": "ms-vscode.cmake-tools",
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "bit": "cpp",
        "system_error": "cpp",
        "xmemory": "cpp",
        "xstring": "cpp",
        "functional": "cpp",
        "fstream": "cpp",
        "sstream": "cpp",
        "stdexcept": "cpp",
        "tuple": "cpp",
        "typeinfo": "cpp"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": 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"
}
Custom browse configuration: 
{
    "browsePath": [
        "c:/users/myuser/source/repos/myrepo/build/mysubrepo",
        "c:/users/myuser/source/repos/myrepo/mysubrepo/src",
        "c:/msys64/ucrt64/include/sdl2",
        "c:/users/myuser/source/repos/myrepo/mysubrepo/examples",
        "c:/users/myuser/source/repos/myrepo/build/cmakefiles",
        "c:/users/myuser/source/repos/myrepo/mysubrepo/test",
        "c:/users/myuser/source/repos/myrepo/mysubrepo/test/std",
 
    ],
    "compilerPath": "c:/msys64/ucrt64/bin/g++.exe",
    "compilerArgs": [],
    "compilerFragments": [
        "-g -std=gnu++20"
    ]
}
cpptools version (native): 1.26.3.0
Current database path: C:\USERS\myuser\APPDATA\LOCAL\MICROSOFT\VSCODE-CPPTOOLS\9AA52F4695B780FC51C3D0DF0D8FC15D\.BROWSE.VC.DB
Translation Unit Mappings:
[ C:\Users\myuser\source\repos\myrepo\myrepo\src\audio\converters\IRateConverter.cpp - source TU]:
    C:\Users\myuser\source\repos\myrepo\myrepo\src\audio\converters\IRateConverter.hpp
Translation Unit Configurations:
[ C:\Users\myuser\source\repos\myrepo\myrepo\src\audio\converters\IRateConverter.cpp ]
    Process ID: 27032
    Memory Usage: 237 MB
    Compiler Path: C:\msys64\ucrt64\bin\g++.exe
    Include paths:
        include: C:\Users\myuser\source\repos\myrepo\build\myrepo
        include: C:\Users\myuser\source\repos\myrepo\myrepo\src
        include: C:\msys64\ucrt64\include\SDL2
        system include: C:\msys64\ucrt64\include\c++\15.1.0
        system include: C:\msys64\ucrt64\include\c++\15.1.0\x86_64-w64-mingw32
        system include: C:\msys64\ucrt64\include\c++\15.1.0\backward
        system include: C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.1.0\include
        system include: C:\msys64\ucrt64\include
        system include: C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.1.0\include-fixed
    Standard Version: c++20
    IntelliSense Mode: windows-gcc-x64
    Other Flags:
        --g++
        --gnu_version=150100
Total Memory Usage: 237 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 8179
Number of files parsed: 805

Other Extensions

No response

Additional context

after dumping log diagnostic i noticed: "intelliSenseMode": "windows-msvc-x64"

then i edited to "intelliSenseMode": "windows-gcc-x64",, reset the intellisense db, but nothing change still same error displayed by intellisense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServiceVisual StudioInherited from Visual StudiobugfixedCheck the Milestone for the release in which the fix is or will be available.parser

    Type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions