Skip to content

book: fix contradictory description of foo(NULL) overload resolution#312

Merged
changkun merged 1 commit into
masterfrom
fix/301-nullptr
Jun 7, 2026
Merged

book: fix contradictory description of foo(NULL) overload resolution#312
changkun merged 1 commit into
masterfrom
fix/301-nullptr

Conversation

@changkun

@changkun changkun commented Jun 7, 2026

Copy link
Copy Markdown
Owner

The narrative claimed foo(NULL) calls foo(int), but the code comment (and clang, the recommended compiler) says it does not compile. These contradicted each other. The behavior is implementation-dependent: NULL as 0 (e.g. MSVC) → calls foo(int); NULL as the GCC/Clang builtin __null → ambiguous, fails to compile. Reword to make this explicit, which also addresses the MSVC observation in the report.

Fixes #301

The narrative claimed foo(NULL) calls foo(int), but the code comment
(and clang, the compiler the example recommends) says it does not
compile. These contradicted each other. The behavior is actually
implementation-dependent: with NULL defined as 0 (e.g. MSVC) it calls
foo(int); with NULL defined as the GCC/Clang builtin __null it is
ambiguous and fails to compile. Reword to make this explicit, which
also addresses the MSVC observation in the report.

Fixes #301
@changkun changkun merged commit f910971 into master Jun 7, 2026
@changkun changkun deleted the fix/301-nullptr branch June 7, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

可否像维基百科一样引入争议性内容出处。

1 participant