Skip to content

[clang] [modules] Clang accepts ill-formed program with main attached to named module #146229

@ashwinbanwari

Description

@ashwinbanwari

According to § 6.9.3.1,

A program that declares
—(3.1) a variable main that belongs to the global scope, or
—(3.2) a function main that belongs to the global scope and is attached to a named module, or
—(3.3) a function template main that belongs to the global scope, or
—(3.4) an entity named main with C language linkage (in any namespace)
is ill-formed. The name main is not otherwise reserved

But having main attached to a named module appears to compile without error with clang as of version 20.1.6.

https://godbolt.org/z/x3nYYfvo7

gcc 15.1 correctly reports:

main.cpp:3:5: error: cannot attach '::main' to a named module
    3 | int main() {}

I would like to self-assign this issue.

Metadata

Metadata

Assignees

Labels

clang:modulesC++20 modules and Clang Header Modules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions