Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>yes some compilers don't give warnings by default for implicit functions

Broken or ancient compilers. That's as much C's fault as it's Intel's fault that Windows 10 doesn't run on Pentium MMX. Implicit functions are not part of C; they were gotten rid of back in 1999!



I agree to some extent (I'd also add that undisciplined and apathetic programmers are an even bigger problem).

I have to disagree about implicit functions not being a part of C anymore. I've yet to see one generate an error; this is optional, and frequently not used. I'm including brand new, state of the art compilers, even (default) gcc. Of course, not even emitting a warning is bananas.

I confirmed this, with the following snippet:

// start fail.c

int fail = 0;

// end fail.c

int main(void)

{

   fail();
   return 0;
}

gcc --std=c99 -g main.c fail.c -o main.exe && gdb main.exe -ex run

# Cmd line junk, however a warning was emitted for implicit function "fail"

Program received signal SIGSEGV, Segmentation fault.

0x00407020 in fail ()


>I have to disagree about implicit functions not being a part of C anymore. I've yet to see one generate an error;

This is not really a debatable matter. There's an international standard for what is, and what is not a part of the C language.

Errors as you seem to understand them are optional for everything else except for the #error preprocessor directive. For all the other invalid C programs, only a diagnostic (like the warning you got) is required, and a conforming implementation is free to complete translating the invalid translation unit. I don't see why that would be an issue, as it's very easy to switch those warnings into translation errors if wanted.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: