[PATCH] D28472: Move _PairT declaration out of __hash_combine to avoid warning under C++98

Dimitry Andric via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 9 10:59:23 PST 2017

dim created this revision.
dim added reviewers: EricWF, mclow.lists.
dim added subscribers: emaste, cfe-commits.

Some parts of the FreeBSD tree are still compiled with C++98, and until
https://reviews.llvm.org/rL288554 this has always worked fine.  After that, a complaint about the
newly introduced local _PairT is produced:

  /usr/include/c++/v1/memory:3354:27: error: template argument uses local type '_PairT' [-Werror,-Wlocal-type-template-args]
      typedef __scalar_hash<_PairT> _HashT;
  /usr/include/c++/v1/memory:3284:29: error: template argument uses local type '_PairT' [-Werror,-Wlocal-type-template-args]
      : public unary_function<_Tp, size_t>
  /usr/include/c++/v1/memory:3356:12: note: in instantiation of template class 'std::__1::__scalar_hash<_PairT, 2>' requested here
      return _HashT()(__p);

As far as I can see, there should be no problem moving the _PairT
struct to just before the __hash_combine() function, which fixes this
particular warning.



Index: include/memory
--- include/memory
+++ include/memory
@@ -3344,12 +3344,13 @@
+struct _PairT {
+  size_t first;
+  size_t second;
 inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT {
-    struct _PairT {
-      size_t first;
-      size_t second;
-    };
     typedef __scalar_hash<_PairT> _HashT;
     const _PairT __p = {__lhs, __rhs};
     return _HashT()(__p);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28472.83654.patch
Type: text/x-patch
Size: 502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170109/745b9cee/attachment.bin>

More information about the cfe-commits mailing list