On Sun, Mar 01, 2009 at 10:40:40AM +0200, Kalle Olavi Niemitalo wrote:
> results in a warning:
> hoh.c: In function ‘main’:
> hoh.c:4: warning: comparison with string literal results in unspecified 
> behavior
> The warning claims the behaviour is unspecified.

The warning is correct. The behaviour is undefined.

> But actually this comparison must always evaluate to false
> because the strings consist of different characters and
> must thus have different addresses.

§6.4.5 6) say:
| It is unspecified whether these arrays are distinct provided their
| elements have the appropriate values.

Also string literals are no pointers and don't need to have an address.

> A gcc-help thread about this warning indicates it is intended to
> warn about only those uses that really are unspecified:
> http://news.gmane.org/find-root.php?message_id=<4794757e.3020...@redhat.com>

I don't see why this is no the case here.

Bastian

-- 
Lots of people drink from the wrong bottle sometimes.
                -- Edith Keeler, "The City on the Edge of Forever",
                   stardate unknown



--
To UNSUBSCRIBE, email to debian-gcc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to