Issue 146229
Summary [clang] [modules] Clang accepts ill-formed program with main attached to named module
Labels clang
Assignees
Reporter 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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to