Bug 41431

Summary: &main should be allowed within unevaluated operands.
Product: gcc Reporter: Johannes Schaub <schaub.johannes>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 4.4.1   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target: i686-pc-linux-gnu
Build: Known to work:
Known to fail: Last reconfirmed:

Description Johannes Schaub 2009-09-21 21:38:59 UTC
The following code snippet is wrongly rejected

int main() { sizeof(&main); }

---
main.cpp: In function 'int main()':
main.cpp:1: warning: ISO C++ forbids taking address of function '::main'
---

But the Standard allows that within a sizeof, because according to 3.2/2 it does not constitute a "use" of main.
Comment 1 Paolo Carlini 2011-09-28 21:34:31 UTC
Fixed in 4.5.x or even earlier.