public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "thakis at chromium dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/61596] -Wunused-local-typedefs warns incorrectly on a typedef that's referenced indirectly
Date: Mon, 28 Jul 2014 01:53:00 -0000	[thread overview]
Message-ID: <bug-61596-4-lH47ET77So@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-61596-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from thakis at chromium dot org ---
Here's a similar example that doesn't need C++1y, regular C++11 is sufficient:

thakis@ubu:~$ cat test.cc
template <class T>
void template_fun(T t) {
  typename T::Foo s3foo;  // YYY
  (void)s3foo;
}
void template_fun_user() {
  struct Local {
    typedef int Foo;  // XXX
  } p;
  template_fun(p);
}
thakis@ubu:~$ g++ -c test.cc -std=c++11 -Wall
test.cc: In function ‘void template_fun_user()’:
test.cc:8:17: warning: typedef ‘template_fun_user()::Local::Foo’ locally
defined but not used [-Wunused-local-typedefs]
     typedef int Foo;
                 ^


Maybe a possible fix is to store all typedefs that get this warning as
candidates, and then emit warnings at the end of the translation unit for all
candidates that are still unreferenced at that point.
>From gcc-bugs-return-457204-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jul 28 04:34:57 2014
Return-Path: <gcc-bugs-return-457204-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 1241 invoked by alias); 28 Jul 2014 04:34:56 -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 1181 invoked by uid 48); 28 Jul 2014 04:34:50 -0000
From: "ishiura-compiler at ml dot kwansei.ac.jp" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/61931] New: Wrong Constant Folding
Date: Mon, 28 Jul 2014 04:34:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 4.8.4
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ishiura-compiler at ml dot kwansei.ac.jp
X-Bugzilla-Status: UNCONFIRMED
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_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-61931-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-07/txt/msg01795.txt.bz2
Content-length: 3088

https://gcc.gnu.org/bugzilla/show_bug.cgi?ida931

            Bug ID: 61931
           Summary: Wrong Constant Folding
           Product: gcc
           Version: 4.8.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.8.4 for arm miscompiles the following code.

  $ cat test.c

  int a, b, c, d, e, f, g, h;
  long long i;
  int
  main (void)
  {
    int j;
    i = a - ((((b | ((1LL * c) >> 1)) / 3) | (1 << (1 / (e + 1)))) | 1);
    j = ((((1 % (1LLU << f)) & (((1LLU >> h)) - (63LLU * d)))) << 1) == ((1LL %
(g + 1)) * a);
    if (i == 1);
    else
    __builtin_printf ("%lld, j = %lld\n", 0, j);
  }

  $ arm-none-eabi-gcc-4.8.4 test.c -o test.out -O1 --specs=rdimon.specs
  $ qemu-arm -L /usr/arm-linux-gnueabihf/ ./test.out
  1, j = 0

  $ arm-none-eabi-gcc-4.8.4 test.c -o test.out -O0 --specs=rdimon.specs
  $ qemu-arm -L /usr/arm-linux-gnueabihf/ ./test.out
  -12884901887, j = 0

  $ arm-none-eabi-gcc-4.8.4 -v
  Using built-in specs.
  COLLECT_GCC=arm-none-eabi-gcc-4.8.4

COLLECT_LTO_WRAPPER=/home/ishiuraken/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.8.4/lto-wrapper
  Target: arm-none-eabi
  Configured with: /home/build/work/GCC-4-8-build/src/gcc/configure
--target=arm-none-eabi --prefix=/home/build/work/GCC-4-8-build/install-native
--libexecdir=/home/build/work/GCC-4-8-build/install-native/lib
--infodir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/info
--mandir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/man
--htmldir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/html
--pdfdir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/pdf
--enable-languages=c,c++ --enable-plugins --disable-decimal-float
--disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath
--disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared
--disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib
--with-headers=yes --with-python-dir=share/gcc-arm-none-eabi
--with-sysroot=/home/build/work/GCC-4-8-build/install-native/arm-none-eabi
--build=i686-linux-gnu --host=i686-linux-gnu
--with-gmp=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-mpfr=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-mpc=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-isl=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-cloog=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-libelf=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
--with-pkgversion='GNU Tools for ARM Embedded Processors'
--with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r
  Thread model: single
  gcc version 4.8.4 20140526 (release) [ARM/embedded-4_8-branch revision
211358] (GNU Tools for ARM Embedded Processors)


  parent reply	other threads:[~2014-07-28  1:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-24 16:49 [Bug c++/61596] New: " thakis at chromium dot org
2014-06-26 17:01 ` [Bug c++/61596] " paolo.carlini at oracle dot com
2014-07-28  1:53 ` thakis at chromium dot org [this message]
2022-01-24 12:29 ` redi at gcc dot gnu.org
2022-01-25 21:09 ` cvs-commit at gcc dot gnu.org
2022-03-07 10:46 ` redi at gcc dot gnu.org
2022-10-30 20:13 ` pinskia 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-61596-4-lH47ET77So@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).