Skip to content

Clang 21 accepts invalid # 0 preprocessor lines leading to undefined behavior at compile time #137846

Open
@mariete1223

Description

@mariete1223

Summary

Clang 21 accepts invalid standalone # 0 preprocessor lines in C source files without emitting an error or a warning. When compiled, the program exhibits undefined behavior (e.g., prints unlimited spaces or crashes), despite the code being syntactically invalid.

Program

uint32_t square(uint32_t x)
# 0
# 0

To reproduce Quickly

https://gcc.godbolt.org/z/c1daT34v6

It gets:

[Truncated]
Compiler returned: 143

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepts-invalidclang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyregression:16Regression in 16 release

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions