P
Paul Melis
Can someone explain to me why the following code compiles without
errors on gcc 4.0.2?
void f()
{
}
void t()
{
f(1,2,3);
f("1");
}
I would expect at least some warning, but not even that. Is this a
feature of the newest C dialect or something, that you can provide
arbitrary arguments to a function having no arguments?
Paul
And yes, I'm compiling the right file:
12:58|paul@tabu:/tmp> gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --
infodir=/usr/share/info --enable-shared --enable-threads=posix --
enable-checking=release --with-system-zlib --enable-__cxa_atexit --
disable-libunwind-exceptions --enable-libgcj-multifile --enable-
languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-
home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Thread model: posix
gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)
12:58|paul@tabu:/tmp> cat t.c
void f()
{
}
void t()
{
f(1,2,3);
f("1");
}
int
main()
{
t();
return 0;
}
12:58|paul@tabu:/tmp> gcc -o t -W -Wall t.c
12:58|paul@tabu:/tmp> ls -l t
-rwxrwxr-x 1 paul paul 4659 Nov 5 12:58 t
errors on gcc 4.0.2?
void f()
{
}
void t()
{
f(1,2,3);
f("1");
}
I would expect at least some warning, but not even that. Is this a
feature of the newest C dialect or something, that you can provide
arbitrary arguments to a function having no arguments?
Paul
And yes, I'm compiling the right file:
12:58|paul@tabu:/tmp> gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --
infodir=/usr/share/info --enable-shared --enable-threads=posix --
enable-checking=release --with-system-zlib --enable-__cxa_atexit --
disable-libunwind-exceptions --enable-libgcj-multifile --enable-
languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-
home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Thread model: posix
gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)
12:58|paul@tabu:/tmp> cat t.c
void f()
{
}
void t()
{
f(1,2,3);
f("1");
}
int
main()
{
t();
return 0;
}
12:58|paul@tabu:/tmp> gcc -o t -W -Wall t.c
12:58|paul@tabu:/tmp> ls -l t
-rwxrwxr-x 1 paul paul 4659 Nov 5 12:58 t