<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/146229>146229</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] [modules] Clang accepts ill-formed program with main attached to named module
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ashwinbanwari
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVE2P6zYM_DX0hVhDlvx58MHJNkDvvbyjLDO2-mTJkOSk219fyN62r7tdoECBAEoAzpAzw1CGoGdL1EN1geo1k3tcnO9lWJ7ajtI-pdfZ6Ka3flDK-UnbGaNDuHIYGqzzLhd5AfwKbICavX_YMODm3ezlinGRESdSRnoKqeonDi2DrgTeHtAOJT6k13I0hKvU9oSMZJydQ2oWF8LZuFEaDMptBPyKzn_i4ifXfbcqamf_GxdKO6EOKGOUaqEp1Ui0cqUJVzft5qtu4kO3SOtmZPx_EsqD1CLZqOPbn2MkwqeOC17RSDvvciY02n5PL_BWW5T2LA6bVAS8AzbogNqYl7vzK005_rLQUXGy6YDWRXRxIf_UgdBTIP-g6UOMwIbLHnGRj5T7Af3aKJTbRtIfepVbN23oGNvtEcl7508RKmlAGdDd8UE-JPM4y4u8zs-OS4xbADEAvwG_zW4anYm58zPw2-_Ab78J--3b_eGas3xWCosqL1A570lF84aeNufjwfFPPUlBrrYNxCBADBWI4RwtfVHSJlNOgQi8SXhxYIA3_7IYbEBEFAjNFbWNeFa2KUNoLtC8fnbzZ3y63Uxo9HdKjIHM_eX8D2JcUmYh7JRnUy-mTnQyo75oqqIQomnLbOk7ea_F2DSsKUfR8urOGzUWDRsZ0dTKOtM9Z7xiNW-LlglW5qJVTLXjyKgUdckmKBmtUpvcmMeaXM2Oln1R1px3mZEjmXBcA86PqIDzdBh8nwAv4z4HKJnRIYa_KaKO5jghJ6J6Ragup0sh_bqemStFW_xxL_-6EsdmfNqvH93Odm_6D6uh47KPuXIr8Fua5f152bz7lVQEfju0BeC3d3mPnv8RAAD__-W-kTU">