Can a void-returning function g return f(); when f returns void?

后端 未结 3 1215
不知归路
不知归路 2020-12-30 23:26

Consider the following snippet:

void f(void);

void g(…)
{
  …
  return f();
  …
}

Is this return f(); valid according to C11?

3条回答
  •  悲&欢浪女
    2020-12-31 00:17

    This clearly is a constraint violation, in particular in view of

    6.3.2.2 void: The (nonexistent) value of a void expression (an expression that has type void) shall not be used in any way,

    That means that the incomplete type void is a dead end that cannot be reused for any purpose whatsoever.

提交回复
热议问题