Skip to content

C/C++ IntelliSense: Size of std::unique_ptr (Empty Type Optimization?) #14524

Description

@huhu9001

Environment

VSCode Version: 1.120.0
OS: Linux x64 7.0.6-200.fc44.x86_64
C/C++ Extension: 1.32.2

Bug Summary and Steps to Reproduce

Bug Summary:

Steps to reproduce:

#include<memory>
int main() {
static_assert(sizeof(std::unique_ptr<size_t[]>) == sizeof(void*));
return 0;
}

static assertion failed C/C++(2784)
the final comparison was 16 == 8

Expected behavior:

As g++ compiles this file normally I assume there should be no error.

Configuration and Logs

-------- Diagnostics - 5/15/2026, 10:15:28 PM
Version: 1.32.2
Current Configuration:
{
"name": "Linux",
"includePath": [],
"defines": [
"_GLIBCXX_DO_NOT_USE_BUILTIN_TRAITS"
],
"compilerPath": "/usr/bin/g++",
"cStandard": "c17",
"cppStandard": "c++23",
"intelliSenseMode": "linux-gcc-x64",
"compilerPathIsExplicit": true,
"cStandardIsExplicit": true,
"cppStandardIsExplicit": true,
"intelliSenseModeIsExplicit": true,
"recursiveIncludesReduceIsExplicit": false,
"recursiveIncludesPriorityIsExplicit": false,
"recursiveIncludesOrderIsExplicit": false,
"compilerPathInCppPropertiesJson": "/usr/bin/g++",
"mergeConfigurations": false,
"recursiveIncludes": {},
"browse": {
"limitSymbolsToIncludedHeaders": true
}
}
Additional Tracked Settings:
{
"editorTabSize": 4,
"editorInsertSpaces": true,
"editorAutoClosingBrackets": "languageDefined",
"filesEncoding": "utf8",
"filesAssociations": {},
"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"
}
cpptools version (native): 1.32.2.0
Current database path: /home/_/.cache/vscode-cpptools/ee064ba49b1a618011b06cc8cd61a68e/.browse.VC.db
Translation Unit Mappings:
[ /home/_/_/src/test/t1.cpp - source TU]:
Translation Unit Configurations:
[ /home/_/_/src/test/t1.cpp ]
Process ID: 40301
Memory Usage: 139 MB
Compiler Path: /usr/bin/g++
Include Paths:
system include: /usr/include/c++/16
system include: /usr/include/c++/16/x86_64-redhat-linux
system include: /usr/include/c++/16/backward
system include: /usr/lib/gcc/x86_64-redhat-linux/16/include
system include: /usr/local/include
system include: /usr/include
Defines:
_GLIBCXX_DO_NOT_USE_BUILTIN_TRAITS
Standard Version: c++23
IntelliSense Mode: linux-gcc-x64
Other Flags:
--g++
--gnu_version=160101
Total Memory Usage: 139 MB
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 96223
Number of files parsed: 6759

Other Extensions

No response

Additional context

GNU STL's std::unique_ptr seems to store the data as std::tuple<T*, std::default_delete<T>>. Likely GCC thinks std::tuple's member can be optimized away while the IDE doesn't.

Metadata

Metadata

Labels

Language ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.verifiedBug has been reproduced

Type

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions