public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/95149] New: lex.c:1729:8: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
Date: Fri, 15 May 2020 10:26:59 +0000	[thread overview]
Message-ID: <bug-95149-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95149

            Bug ID: 95149
           Summary: lex.c:1729:8: warning: result of comparison against a
                    string literal is unspecified (use an explicit string
                    comparison function instead) [-Wstring-compare]
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: jason at gcc dot gnu.org, nathan at gcc dot gnu.org
  Target Milestone: ---

I see the following Clang warnings for lex.c. It comes from:

1729:         BUF_APPEND ("\\", 1);

#define BUF_APPEND(STR,LEN)                                     \
      do {                                                      \
        bufring_append (pfile, (const uchar *)(STR), (LEN),     \
                        &first_buff, &last_buff);               \
        total_len += (LEN);                                     \
        if (__builtin_expect (temp_buffer_len < 17, 0)          \
            && (const uchar *)(STR) != base                     \
            && (LEN) <= 2)                                      \
          {                                                     \
            memcpy (temp_buffer + temp_buffer_len,              \
                    (const uchar *)(STR), (LEN));               \
            temp_buffer_len += (LEN);                           \
          }                                                     \
      } while (0)

If I see correctly the problematic comparison is '(const uchar *)(STR) != base'
which is really a comparison in between a string literal and a local variable.

             reply	other threads:[~2020-05-15 10:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15 10:26 marxin at gcc dot gnu.org [this message]
2020-05-15 10:32 ` [Bug c++/95149] " jakub at gcc dot gnu.org
2020-05-15 10:36 ` jakub at gcc dot gnu.org
2020-05-15 11:09 ` pinskia at gcc dot gnu.org
2020-05-19 18:41 ` nathan at gcc dot gnu.org
2020-05-19 19:27 ` marxin at gcc dot gnu.org

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=bug-95149-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).