surprising semantics of the && expression
Walter Bright
newshound2 at digitalmars.com
Wed Feb 4 18:08:33 UTC 2026
On 2/4/2026 1:20 AM, Timon Gehr wrote:
> Compiles as C as well as D:
>
> ```c
> auto foo(){}
>
> void main(){
> int b = 1;
> b && foo();
> }
> ```
```c
int foo() { }
```
compiles without complaint from C.
The reason is historical, as K+R C did not require a function to annotate its
return type, and defaulted to int. K+R C did not have a void type.
More information about the Digitalmars-d
mailing list