[lld] r274518 - [OutputSection] Work around GCC not being able to deduce auto.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 4 12:49:55 PDT 2016


Author: davide
Date: Mon Jul  4 14:49:55 2016
New Revision: 274518

URL: http://llvm.org/viewvc/llvm-project?rev=274518&view=rev
Log:
[OutputSection] Work around GCC not being able to deduce auto.

The build otherwise fails with:
[ 39%] Building CXX object
tools/lld/ELF/CMakeFiles/lldELF.dir/OutputSections.cpp.o
/export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp: In
member function ‘void
lld::elf::GnuHashTableSection<ELFT>::addSymbols(std::vector<std::pair<lld::elf::SymbolBody*,
long unsigned int> >&)’:
/export/gnu/import/git/llvm/tools/lld/ELF/OutputSections.cpp:585:8:
error: inconsistent deduction for ‘auto’: ‘auto’ and then
‘__gnu_cxx::__normal_iterator<std::pair<lld::elf::SymbolBody*, long
unsigned int>*, std::vector<std::pair<lld::elf::SymbolBody*, long
unsigned int> > >’

Reported by:  H. J. Liu

Modified:
    lld/trunk/ELF/OutputSections.cpp

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=274518&r1=274517&r2=274518&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Mon Jul  4 14:49:55 2016
@@ -576,13 +576,18 @@ void GnuHashTableSection<ELFT>::writeHas
 template <class ELFT>
 void GnuHashTableSection<ELFT>::addSymbols(
     std::vector<std::pair<SymbolBody *, size_t>> &V) {
-  auto Mid = std::stable_partition(V.begin(), V.end(),
-                                   [](std::pair<SymbolBody *, size_t> &P) {
-                                     return P.first->isUndefined();
-                                   });
+  // Ideally this will just be 'auto' but GCC 6.1 is not able
+  // to deduce it correctly.
+  std::vector<std::pair<SymbolBody *, size_t>>::iterator Mid =
+      std::stable_partition(V.begin(), V.end(),
+                            [](std::pair<SymbolBody *, size_t> &P) {
+                              return P.first->isUndefined();
+                            });
   if (Mid == V.end())
     return;
-  for (auto I = Mid, E = V.end(); I != E; ++I) {
+  for (std::vector<std::pair<SymbolBody *, size_t>>::iterator I = Mid,
+                                                              E = V.end();
+       I != E; ++I) {
     SymbolBody *B = I->first;
     size_t StrOff = I->second;
     Symbols.push_back({B, StrOff, hashGnu(B->getName())});




More information about the llvm-commits mailing list