I was wondering why does the following code not throw an error during compilation? :
#include <stdio.h>
char * func (char *);
int main()
{
func("TINFO");
func("INFO");
}
char * func(char * str)
{
if (str[0] == 'T')
return str + 1;
}
You see there is a return path from the function that does not return a char *
Similar Java code throws a compile time error, though.
Compiler used:
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3