[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#517653: gcc-4.3: "warning: comparison with string literal results in unspecified behavior" when comparing two different literals



package gcc-4.3
found 517653 gcc-4.4/4.4.7-1
found 517653 gcc-4.6/4.6.3-1
found 517653 gcc-4.7/4.7.0-3
quit

Kalle Olavi Niemitalo <kon@iki.fi> writes:

> Compiling this with gcc-4.3 -Wall -c
>
> int
> main (void)
> {
>   return "hello" == "there";
> }
>
> results in a warning:
>
> hoh.c: In function ‘main’:
> hoh.c:4: warning: comparison with string literal results in unspecified behavior

The same happens with more recent versions:

% gcc-4.4 -Wall -c hoh.c
hoh.c: In function ‘main’:
hoh.c:4: warning: comparison with string literal results in unspecified behavior
% gcc-4.6 -Wall -c hoh.c
hoh.c: In function ‘main’:
hoh.c:4:18: warning: comparison with string literal results in unspecified behavior [-Waddress]
% gcc-4.7 -Wall -c hoh.c
hoh.c: In function ‘main’:
hoh.c:4:18: warning: comparison with string literal results in unspecified behavior [-Waddress]
% dpkg -l gcc-4.4 gcc-4.6 gcc-4.7
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
ii  gcc-4.4        4.4.7-1        GNU C compiler
ii  gcc-4.6        4.6.3-1        GNU C compiler
ii  gcc-4.7        4.7.0-3        GNU C compiler

Attachment: pgpYvMMo30DXx.pgp
Description: PGP signature


Reply to: