[llvm-bugs] [Bug 24883] New: clang++ uncorrecly report unused typedef

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Sep 19 10:27:48 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24883

            Bug ID: 24883
           Summary: clang++ uncorrecly report unused typedef
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: natale.patriciello at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Hi,

since the release of XCode 7.0 with the lastest clang, ns-3 (a network
simulator) compilation produces a warning, which is not raised by gcc or older
version of clang.

I'm not able to produce a minimal piece of code which represents the (IMHO) bug
in clang. The step to download and compile ns-3 are:

$ git clone https://github.com/nsnam/ns-3-dev-git.git
$ cd ns-3-dev-git
$ CXX="clang++" ./waf configure --enable-examples --enable-tests
$ ./waf -j1

after an initial generation phase, the warning (and, as consequence of using
-Werror, the error) steps in:

[ 823/2351] Compiling examples/wireless/wifi-ap.cc
In file included from ../examples/wireless/wifi-ap.cc:22:
In file included from ./ns3/core-module.h:29:
In file included from ./ns3/event-garbage-collector.h:25:
In file included from ./ns3/simulator.h:26:
./ns3/make-event.h:510:20: error: unused typedef 'F'
[-Werror,-Wunused-local-typedef]
    typedef void (*F)(U1);
                   ^
1 error generated.


The incriminated snippet is the following, from the file you can find under
build/ns3/make-event.h :

template <typename U1, typename T1>
EventImpl * MakeEvent (void (*f)(U1), T1 a1)
{
  // one arg version
  class EventFunctionImpl1 : public EventImpl
  {
public:
    typedef void (*F)(U1);

    EventFunctionImpl1 (F function, T1 a1)
      : m_function (function),
        m_a1 (a1)
    {
    }
protected:
    virtual ~EventFunctionImpl1 ()
    {
    }
private:
    virtual void Notify (void)
    {
      (*m_function)(m_a1);
    }
    F m_function;
    typename TypeTraits<T1>::ReferencedType m_a1;
  } *ev = new EventFunctionImpl1 (f, a1);
  return ev;
}

Im my opinion, the typedef is used shortly after, so it's pretty strange to see
it as "unused". As said, neither gcc or previous version of clang reported this
error.


 To be honest, different users are reporting slightly different version of this
bug; see for example
https://groups.google.com/forum/#!topic/ns-3-users/tNRGHZMX5gs . In that link,
the error refers to the 5-args version of MakeEvent, while I'm having it for
the single-argument version. Maybe it's because I'm using Linux and the user is
using Mac OS; anyway, there's my version of the software:

$ clang --version
clang version 3.6.2 (tags/RELEASE_362/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

$ llvm-ar --version
LLVM (http://llvm.org/):
  LLVM version 3.6.2
  Optimized build.
  Built Sep  7 2015 (18:01:20).
  Default target: x86_64-unknown-linux-gnu
  Host CPU: corei7-avx


Thank you.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150919/5b9f3890/attachment.html>


More information about the llvm-bugs mailing list