public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Russell Shaw <rjshaw@netspace.net.au>
Cc: gcc-help@gcc.gnu.org
Subject: Re: warning: comparison with string literal results in unspecified   behaviour
Date: Tue, 22 Jan 2008 11:29:00 -0000	[thread overview]
Message-ID: <4793ED01.50108@netspace.net.au> (raw)
In-Reply-To: <47937327.6010105@redhat.com>

Andrew Haley wrote:
> Russell Shaw wrote:
>> How do i disable that? My code explicitly compares string pointers.
> 
> The best way is to intern all your strings.  String interning is a
> fairly common efficient technique and you can look it up in Google.

I've seen that in Xlib code. There's no reason to do it if you're
not storing strings on a remote host.

I store pointers to const strings in various objects and use them
much like magic numbers, so direct pointer comparisons are the ideal
thing to do.

This warning never happened on older gcc versions.

Infact, the warning is incorrect for this valid use.

It's just unnecessary nannying.

I've been using it in thousands of lines of code for 5 years.

  reply	other threads:[~2008-01-21  0:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-21 11:20 Russell Shaw
2008-01-21 21:59 ` Andrew Haley
2008-01-22 11:29   ` Russell Shaw [this message]
2008-01-22 12:32     ` Andrew Haley
2008-01-22 12:48       ` Russell Shaw
2008-01-22 13:25         ` Russell Shaw
2008-01-22 13:31           ` Russell Shaw
2008-01-22 13:45             ` Andrew Haley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4793ED01.50108@netspace.net.au \
    --to=rjshaw@netspace.net.au \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).