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

            Bug ID: 79698
           Summary: spurious -Wunused-local-typedefs on a typedef used by
                    a template
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

GCC issues the -Wunused-local-typedefs warning for the typedef defined in
struct B in the function template f() below even though the typedef is used. 
Clang handles this case correctly.

$ cat t.C && gcc -S -Wall -Wextra -Wpedantic -Wunused-local-typedefs t.C
template <class T>
struct A {
  typedef typename T::U U;
  U u;
};

template <class T>
T f ()
{
  struct B {
    typedef T U;
  };

  return typename A<B>::U ();
}
t.C: In function ā€˜T f()ā€™:
t.C:11:15: warning: typedef ā€˜f()::B::Uā€™ locally defined but not used
[-Wunused-local-typedefs]
     typedef T U;
               ^

Reply via email to