Skip to content

Fix: 2 typos in variant section#33

Merged
Charliechen114514 merged 1 commit into
Awesome-Embedded-Learning-Studio:mainfrom
YukunJ:fix-bug
Jun 7, 2026
Merged

Fix: 2 typos in variant section#33
Charliechen114514 merged 1 commit into
Awesome-Embedded-Learning-Studio:mainfrom
YukunJ:fix-bug

Conversation

@YukunJ
Copy link
Copy Markdown
Contributor

@YukunJ YukunJ commented Jun 5, 2026

Brief: Fix 2 typos in std::variant section.

  1. int type usually takes 4 bytes on 64 bit architectures.
  2. std::variant<int, std::string> would take 8 (sizeof(size_t)) + 32 (max(sizeof(int), sizeof(std::string)) storage space then.

Please refer to this for reproduction: https://godbolt.org/z/sbvEMW56G

@Charliechen114514

@Charliechen114514
Copy link
Copy Markdown
Member

Charliechen114514 commented Jun 7, 2026

Review:

  1. Yes, I Do make a typo in std::variant section at line 435, at least cpp reference page siting at: https://en.cppreference.com/cpp/language/types, int is at least 16 bits(2 bytes) at platform LP32.
  2. Verified in both godbolt and my local machine, which is
Item Environment
Operating System Arch Linux x86_64 on WSL2
Kernel 6.6.114.1-microsoft-standard-WSL2
Compiler GCC 16.1.1
C++ Standard C++17 (-std=c++17)
Architecture x86_64, LP64 ABI

Much more appreciate for your help!

审查了以下,的确又搞低级错误了(手动捂脸哭笑

  1. Line 435的确搞错了,因为手册来不及翻,找了下https://en.cppreference.com/cpp/language/types,的确int规定的是最小2字节,其他平台4字节。
  2. 修改正确,自己在godbolt和自己如下环境的本地验证通过
项目 环境
操作系统 Arch Linux x86_64,运行于 WSL2
内核版本 6.6.114.1-microsoft-standard-WSL2
编译器 GCC 16.1.1
C++ 标准 C++17(-std=c++17)
体系结构 x86_64,LP64 ABI

非常感激您的认真阅读和勘误!

@Charliechen114514 Charliechen114514 merged commit ceaac86 into Awesome-Embedded-Learning-Studio:main Jun 7, 2026
4 checks passed
@YukunJ YukunJ deleted the fix-bug branch June 7, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants