Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian GCC (http://www.linux-archive.org/debian-gcc/)
-   -   Bug#517653: gcc-4.3: "warning: comparison with string literal results in unspecified behavior" when comparing two different literals (http://www.linux-archive.org/debian-gcc/663428-bug-517653-gcc-4-3-warning-comparison-string-literal-results-unspecified-behavior-when-comparing-two-different-literals.html)

Kalle Olavi Niemitalo 05-05-2012 04:31 PM

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


All times are GMT. The time now is 10:40 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.