public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/28901] -Wunused-variable ignores unused const initialised variables
Date: Fri, 17 Jan 2014 00:26:00 -0000	[thread overview]
Message-ID: <bug-28901-4-C5p8vEPos7@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-28901-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28901

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Andrew Pinski from comment #3)
> From the code:
>        /* We don't warn about "static const" variables because the
> 	  "rcs_id" idiom uses that construction.  */

That is not a good reason not to warn:

[hjl@gnu-mic-2 gcc]$ cat /tmp/w.c
static const int foo[0x1000];
[hjl@gnu-mic-2 gcc]$ gcc  -Wall -S /tmp/w.c
[hjl@gnu-mic-2 gcc]$ cat w.s
    .file    "w.c"
    .local    foo
    .comm    foo,16384,32
    .ident    "GCC: (GNU) 4.8.2 20140115 (Red Hat 4.8.2-11)"
    .section    .note.GNU-stack,"",@progbits
[hjl@gnu-mic-2 gcc]$ 

If we want to avoid rcs_id warning, we can check it explicitly and
not to warn it.
>From gcc-bugs-return-440649-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jan 17 00:42:30 2014
Return-Path: <gcc-bugs-return-440649-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 19613 invoked by alias); 17 Jan 2014 00:42:29 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 19574 invoked by uid 48); 17 Jan 2014 00:42:26 -0000
From: "hubicka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/55478] [devirt] trunk fails inline-devirt test #4
Date: Fri, 17 Jan 2014 00:42:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 4.8.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: hubicka at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status assigned_to
Message-ID: <bug-55478-4-UvLwZHCBMA@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-55478-4@http.gcc.gnu.org/bugzilla/>
References: <bug-55478-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-01/txt/msg01791.txt.bz2
Content-length: 1047

http://gcc.gnu.org/bugzilla/show_bug.cgi?idU478

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
           Assignee|hubicka at gcc dot gnu.org         |unassigned at gcc dot gnu.org

--- Comment #12 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
print_length is not really a trivial wrapper:
void print_length (const String& string)
{
  for (uint64_t i = 0; i < string.length(); i++)
    {
      printf("%d\n", string.get(i));
    }
}

and the fact that it disappears depends on
 1) ability to inline it
 2) ability to devirtualize length and get calls
 3) ability to eliminate the loop since length is small.

Inlined can anticiapte 1-2 to happen, but not 3 and with -O2 it decides that
code size would grow.

For 3 one would need return functions to start with to determine the constant
bound. So we can get it better only once Martin gets to it ;)


  parent reply	other threads:[~2014-01-17  0:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-28901-4@http.gcc.gnu.org/bugzilla/>
2014-01-16 23:52 ` pinskia at gcc dot gnu.org
2014-01-16 23:55 ` pinskia at gcc dot gnu.org
2014-01-17  0:26 ` hjl.tools at gmail dot com [this message]
2014-02-11 17:39 ` tromey at gcc dot gnu.org
2014-08-08 14:18 ` tromey at gcc dot gnu.org
2014-10-22 18:55 ` petschy at gmail dot com
2015-09-11 22:15 ` mark at gcc dot gnu.org
2015-09-14  9:50 ` mark at gcc dot gnu.org
2015-09-18 23:06 ` eggert at gnu dot org
2015-09-18 23:43 ` manu at gcc dot gnu.org
2015-09-19  4:51 ` eggert at gnu dot org
2015-09-19  9:27 ` manu at gcc dot gnu.org
2006-08-30 11:55 [Bug c/28901] New: " mikpe at csd dot uu dot se
2006-09-19  5:13 ` [Bug c/28901] " pinskia at gcc dot gnu dot 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-28901-4-C5p8vEPos7@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).