What happens with sizeof(main) where main is a function returning int?
Correct answer
A. It is a constraint violation, so a conforming compiler must diagnose it
19 views
A. It is a constraint violation, so a conforming compiler must diagnose it
19 views
The operand of sizeof may not have function type: C11 6.5.3.4 makes sizeof applied to a function a constraint violation, so the compiler must issue a diagnostic. The usual decay of a function designator to a pointer does not happen for sizeof, & or the initialiser of a char array. sizeof of a function pointer, by contrast, is perfectly well defined.
Asked in: NTS, PPSC IT, Campus Interviews
Not sure why the answer is A? Ask here and get an explanation.