<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - clang++ uncorrecly report unused typedef"
   href="https://llvm.org/bugs/show_bug.cgi?id=24883">24883</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang++ uncorrecly report unused typedef
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.7
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>natale.patriciello@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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 <a href="https://github.com/nsnam/ns-3-dev-git.git">https://github.com/nsnam/ns-3-dev-git.git</a>
$ 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
<a href="https://groups.google.com/forum/#!topic/ns-3-users/tNRGHZMX5gs">https://groups.google.com/forum/#!topic/ns-3-users/tNRGHZMX5gs</a> . 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 (<a href="http://llvm.org/">http://llvm.org/</a>):
  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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>