Issue Details (XML | Word | Printable)

Key: PCC-213
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Piotr Sikora
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
pcc

-Werror shows "warnings" instead of "errors"

Created: 13/Jan/11 07:00 AM   Updated: 23/Jan/11 03:24 AM
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Environment: pcc 0.9.9 20110112 for x86_64-unknown-linux-gnu, p@ubuntu


 Description  « Hide
Hello,
it seems that pcc shows "warnings" even when using -Werror:

p@ubuntu:~$ pcc -Wc,-WW hello.c
hello.c, line 2: warning: no prototype for function 'printf()'
p@ubuntu:~$ echo $?
0

p@ubuntu:~$ pcc -Werror -Wc,-WW hello.c
hello.c, line 2: warning: no prototype for function 'printf()'
p@ubuntu:~$ echo $?
1


Both gcc and clang are showing "error" instead of "warning" when used with -Werror, which is IMHO very reasonable behavior:

p@ubuntu:~$ gcc -Wall hello.c
hello.c: In function âmainâ:
hello.c:2: warning: implicit declaration of function âprintfâ
hello.c:2: warning: incompatible implicit declaration of built-in function âprintfâ
p@ubuntu:~$ echo $?
0

p@ubuntu:~$ gcc -Werror -Wall hello.c
cc1: warnings being treated as errors
hello.c: In function âmainâ:
hello.c:2: error: implicit declaration of function âprintfâ
hello.c:2: error: incompatible implicit declaration of built-in function âprintfâ
p@ubuntu:~$ echo $?
1


p@ubuntu:~$ clang -Wall hello.c
hello.c:2:29: warning: implicitly declaring C library function 'printf' with type 'int (char const *, ...)'
int main(int c, char **v) { printf("Hello!\n"); return 0; }
                            ^
hello.c:2:29: note: please include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning generated.
p@ubuntu:~$ echo $?
0

p@ubuntu:~$ clang -Werror -Wall hello.c
hello.c:2:29: error: implicitly declaring C library function 'printf' with type 'int (char const *, ...)'
int main(int c, char **v) { printf("Hello!\n"); return 0; }
                            ^
hello.c:2:29: note: please include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 error generated.
p@ubuntu:~$ echo $?
1

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Piotr Sikora added a comment - 13/Jan/11 07:06 AM
Sorry, this should have "minor" priority.

Anders Magnusson added a comment - 16/Jan/11 08:15 PM
Hm, there seems to be some deeper logic in this:

lab02-amd64:/home/ragge >gcc -Werror -Wall -c x.c
cc1: warnings being treated as errors
x.c:3: warning: return type defaults to 'int'
x.c: In function 'x':
x.c:6: warning: assignment makes integer from pointer without a cast
x.c:7: warning: control reaches end of non-void function
lab02-amd64:/home/ragge >echo $status
1
lab02-amd64:/home/ragge >gcc --version
gcc (GCC) 4.2.1 20070719 [FreeBSD]

so, here doesn't it give it as error...?

Piotr Sikora added a comment - 16/Jan/11 11:00 PM
Indeed, it seems that gcc-4.2 didn't have this behavior.

I did run some tests on all operating systems and compilers that I have available at the moment, the summary is that with -Werror:
- clang-1.1 (llvm 2.7), clang-2.8, clang-2.9 , gcc-4.4, gcc-4.5, gcc-4.6, suncc-5.11 (sun studio 12.2) - show "error" instead of "warning",
- gcc-4.1, gcc-4.2, pcc - keep showing "warning".

(I don't have gcc-4.3 installed anywhere)

The conclusion being that all major compilers, other than pcc, are showing "error" instead of "warning" in recent releases.

Anders Magnusson added a comment - 22/Jan/11 11:10 PM
I checked 4.3 and it did write "error" so I changed the code to do so also, since pcc is mimic 4.3.

Piotr Sikora added a comment - 23/Jan/11 03:24 AM
Much better now, thank you.