http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57465

            Bug ID: 57465
           Summary: Failed postcondition for std::function constructed
                    with null function pointer
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org

#include <functional>
#include <cassert>

int main()
{
  using F = void();
  F* f = nullptr;
  std::function<F> x(f);
  assert( !x );
}

The assert should pass, but it fails with all versions.

Note that clang++ with libstdc++ headers passes the test, so this might be a
front end bug (to be filed separately) but can be fixed/worked around easily
enough in libstdc++ like so:

--- functional.orig     2013-05-30 10:48:27.081623873 +0100
+++ functional  2013-05-30 10:48:29.225370770 +0100
@@ -1964,7 +1964,7 @@

        template<typename _Tp>
          static bool
-         _M_not_empty_function(const _Tp*& __fp)
+         _M_not_empty_function(_Tp* const& __fp)
          { return __fp; }

        template<typename _Class, typename _Tp>

Reply via email to