public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63872] New: -Wunused-local-typedefs warns incorrectly on a typedef that's referenced from a template
@ 2014-11-14 16:26 thakis at chromium dot org
  2014-11-14 16:45 ` [Bug c++/63872] " redi at gcc dot gnu.org
  2014-11-14 17:22 ` thakis at chromium dot org
  0 siblings, 2 replies; 3+ messages in thread
From: thakis at chromium dot org @ 2014-11-14 16:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 63872
           Summary: -Wunused-local-typedefs warns incorrectly on a typedef
                    that's referenced from a template
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thakis at chromium dot org

$ cat test2.cc
typedef char YesType;
struct NoType { YesType dummy[2]; };

template <typename T>
struct ShouldAbortOnSelfReset {
  template <typename U>
  static NoType Test(const typename U::AllowSelfReset*);

  template <typename U>
  static YesType Test(...);

  static const bool value = sizeof(Test<T>(0)) == sizeof(YesType);
};

template<class T>
struct Foo {
  void reset() {
    ShouldAbortOnSelfReset<T>::value;
  }
};

void f() {
  struct NoOpDeleter {
    typedef void AllowSelfReset;
    inline void operator()(int*) {}
  };

  Foo<NoOpDeleter> f;
  f.reset();
}

$ ~/gcc482prefix/bin/gcc -c test2.cc -std=c++11 -Wall
test2.cc: In function ‘void f()’:
test2.cc:24:18: warning: typedef ‘f()::NoOpDeleter::AllowSelfReset’ locally
defined but not used [-Wunused-local-typedefs]
     typedef void AllowSelfReset;
                  ^
test2.cc: In instantiation of ‘void Foo<T>::reset() [with T =
f()::NoOpDeleter]’:
test2.cc:29:11:   required from here


Warning on this is very dangerous, since removing the typedef will change the
meaning of the code but it's still going to compile.

This is with 4.8.2, but it also happens in gcc 4.9.
>From gcc-bugs-return-466775-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Nov 14 16:39:06 2014
Return-Path: <gcc-bugs-return-466775-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 29161 invoked by alias); 14 Nov 2014 16:39:05 -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 29098 invoked by uid 48); 14 Nov 2014 16:39:00 -0000
From: "richard at netbsd dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/63779] g++ 4.9 generates invalid object provoking a GOT relative relocation must reference a local symbol linker error on SunOS
Date: Fri, 14 Nov 2014 16:39:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: richard at netbsd dot org
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:
Message-ID: <bug-63779-4-s9IJCArPYO@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63779-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63779-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-11/txt/msg01247.txt.bz2
Content-length: 644

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

--- Comment #2 from Richard PALO <richard at netbsd dot org> ---
Sorry. Given the size, I'll use the following directory for any information
needed: http://www.netbsd.org/~richard/xulrunner31-g++-issue/

Index of /~richard/xulrunner31-g++-issue

    Parent Directory
    MediaDecoderReader.cpp
    MediaDecoderReader.h
    MediaDecoderReader.ii
    MediaDecoderReader.o
    MediaDecoderReader.o.gkd
    MediaDecoderReader.s
    ld-debug.txt.gz

I included the gzip'd output of the link with:
LD_OPTIONS=-Dfiles,detail,reloc,got,sections,output=ld-debug.txt

Anything else useful to provide?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/63872] -Wunused-local-typedefs warns incorrectly on a typedef that's referenced from a template
  2014-11-14 16:26 [Bug c++/63872] New: -Wunused-local-typedefs warns incorrectly on a typedef that's referenced from a template thakis at chromium dot org
@ 2014-11-14 16:45 ` redi at gcc dot gnu.org
  2014-11-14 17:22 ` thakis at chromium dot org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2014-11-14 16:45 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-11-14
            Version|unknown                     |4.8.2
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
That's just a bug, a typedef defined at class scope is not a local typedef,
even if it's in a local class.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/63872] -Wunused-local-typedefs warns incorrectly on a typedef that's referenced from a template
  2014-11-14 16:26 [Bug c++/63872] New: -Wunused-local-typedefs warns incorrectly on a typedef that's referenced from a template thakis at chromium dot org
  2014-11-14 16:45 ` [Bug c++/63872] " redi at gcc dot gnu.org
@ 2014-11-14 17:22 ` thakis at chromium dot org
  1 sibling, 0 replies; 3+ messages in thread
From: thakis at chromium dot org @ 2014-11-14 17:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from thakis at chromium dot org ---
I think warning on unused typedefs in local classes is generally a useful
feature, not a bug. The bug here is that it's warning on a typedef in a local
class that is being used.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-14 17:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-14 16:26 [Bug c++/63872] New: -Wunused-local-typedefs warns incorrectly on a typedef that's referenced from a template thakis at chromium dot org
2014-11-14 16:45 ` [Bug c++/63872] " redi at gcc dot gnu.org
2014-11-14 17:22 ` thakis at chromium dot org

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).