Skip to content

overload resolution fails for user-define string literal operator templates in an inline/using'd namespace #14158

@marralesfios

Description

@marralesfios

Environment

  • OS and Version: Arch Linux (linux 6.18.7-arch-1 kernel)
  • VS Code Version: 1.108.2 commit c9d77990917f3102ada88be140d28b038d1dd7c7
  • C/C++ Extension Version: 1.30.3
  • If using SSH remote, specify OS of remote machine: N/A

Bug Summary and Steps to Reproduce

Bug Summary:

Whenever a user-defined string literal operator template is placed in a namespace and then that namespace is using'd or declared inline, using said template in the global namespace causes IntelliSense errors.

Steps to reproduce:

  1. Create a new folder with provided c_cpp_properties.json
  2. Create a new file and paste in this code:
#include<cstdint>
#include<string>
template<typename CharT,std::size_t l>
struct basic_template_string{
    CharT arr[l];
    constexpr basic_template_string(const CharT(&a)[l]){
        std::size_t i = l;
        while(i--){
            arr[i] = a[i];
        }
    }
};
template<std::size_t n>
using c_template_string = basic_template_string<char,n>;
template<std::size_t n>
using template_string = basic_template_string<char8_t,n>;
inline namespace literals{
    template<c_template_string s>
    consteval decltype(s) operator ""_ts(){
        return s;
    }
    template<template_string s>
    consteval decltype(s) operator ""_ts(){
        return s;
    }
}
template<template_string,typename ...T>
void foo(T&&...){}
int main(){
    operator ""_ts<u8"Hello!">(); // okay
    foo<u8"Hello!"_ts>(1,2); // error?
    return 0;
}
  1. Scroll down to foo<u8"Hello!"_ts>(1,2); line
  2. See error
Image

Expected behavior:
No error. (Godbolt proof: https://godbolt.org/z/WvMG14TPW)

Configuration and Logs

home folder /home/... redacted with ~ in the following logs.
c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Default",
            "intelliSenseMode": "linux-gcc-x64",
            "compilerPath": "/usr/bin/g++"
        }
    ],
    "version": 4
}

Log Diagnostics result:

-------- Diagnostics - 2/3/2026, 12:17:10 PM
Version: 1.30.3
Current Configuration:
{
    "name": "Default",
    "intelliSenseMode": "linux-gcc-x64",
    "compilerPath": "/usr/bin/g++",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "recursiveIncludesReduceIsExplicit": false,
    "recursiveIncludesPriorityIsExplicit": false,
    "recursiveIncludesOrderIsExplicit": false,
    "compilerPathInCppPropertiesJson": "/usr/bin/g++",
    "includePath": [
        "~/include"
    ],
    "compilerArgs": [
        "-m64"
    ],
    "cStandard": "c23",
    "cppStandard": "c++26",
    "mergeConfigurations": false,
    "recursiveIncludes": {},
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.intelliSenseUpdateDelay": 500,
    "C_Cpp.autocompleteAddParentheses": true,
    "C_Cpp.suggestSnippets": false,
    "C_Cpp.default.includePath": [
        "~/include"
    ],
    "C_Cpp.default.compilerPath": "/usr/bin/g++",
    "C_Cpp.default.compilerArgs": [
        "-m64"
    ],
    "C_Cpp.default.cStandard": "c23",
    "C_Cpp.default.cppStandard": "c++26",
    "C_Cpp.codeAnalysis.updateDelay": 1000,
    "C_Cpp.debugShortcut": false,
    "C_Cpp.loggingLevel": "Debug",
    "C_Cpp.copilotHover": "disabled"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "array": "cpp",
        "atomic": "cpp",
        "bit": "cpp",
        "cctype": "cpp",
        "charconv": "cpp",
        "chrono": "cpp",
        "clocale": "cpp",
        "cmath": "cpp",
        "codecvt": "cpp",
        "compare": "cpp",
        "complex": "cpp",
        "concepts": "cpp",
        "condition_variable": "cpp",
        "cstdarg": "cpp",
        "cstddef": "cpp",
        "cstdint": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cstring": "cpp",
        "ctime": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "deque": "cpp",
        "list": "cpp",
        "map": "cpp",
        "set": "cpp",
        "string": "cpp",
        "unordered_map": "cpp",
        "unordered_set": "cpp",
        "vector": "cpp",
        "exception": "cpp",
        "algorithm": "cpp",
        "functional": "cpp",
        "iterator": "cpp",
        "memory": "cpp",
        "memory_resource": "cpp",
        "numeric": "cpp",
        "optional": "cpp",
        "random": "cpp",
        "ratio": "cpp",
        "string_view": "cpp",
        "system_error": "cpp",
        "tuple": "cpp",
        "type_traits": "cpp",
        "utility": "cpp",
        "format": "cpp",
        "fstream": "cpp",
        "future": "cpp",
        "initializer_list": "cpp",
        "iomanip": "cpp",
        "iosfwd": "cpp",
        "iostream": "cpp",
        "istream": "cpp",
        "limits": "cpp",
        "mutex": "cpp",
        "new": "cpp",
        "numbers": "cpp",
        "ostream": "cpp",
        "queue": "cpp",
        "ranges": "cpp",
        "semaphore": "cpp",
        "span": "cpp",
        "sstream": "cpp",
        "stdexcept": "cpp",
        "stdfloat": "cpp",
        "stop_token": "cpp",
        "streambuf": "cpp",
        "text_encoding": "cpp",
        "thread": "cpp",
        "cinttypes": "cpp",
        "typeinfo": "cpp",
        "valarray": "cpp",
        "variant": "cpp",
        "shared_mutex": "cpp",
        "cfenv": "cpp",
        "print": "cpp",
        "any": "cpp",
        "bitset": "cpp",
        "forward_list": "cpp",
        "stack": "cpp",
        "typeindex": "cpp",
        "*.inc": "cpp",
        "hash_map": "cpp",
        "coroutine": "cpp",
        "source_location": "cpp"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": true,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.30.2.0
Current database path: ~/.cache/vscode-cpptools/3188dd32d309a36ba9b381435fa68e21/.browse.VC.db
Translation Unit Mappings:
[ ~/Projects/cppsandbox/mre.cpp - source TU]:
Translation Unit Configurations:
[ ~/Projects/cppsandbox/mre.cpp ]
    Process ID: 30682
    Memory Usage: 83 MB
    Compiler Path: /usr/bin/g++
    Include paths:
        include: ~/include
        system include: /usr/include/c++/15.2.1
        system include: /usr/include/c++/15.2.1/x86_64-pc-linux-gnu
        system include: /usr/include/c++/15.2.1/backward
        system include: /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/include
        system include: /usr/local/include
        system include: /usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/include-fixed
        system include: /usr/include
    Standard Version: c++26
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --g++
        --gnu_version=150201
Total Memory Usage: 83 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 46672
Number of files parsed: 5884

Language server logging:
lslog.txt

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions