[lld] r274518 - [OutputSection] Work around GCC not being able to deduce auto.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 6 10:35:56 PDT 2016
On Mon, Jul 4, 2016 at 12:49 PM, Davide Italiano via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> 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) {
>
Did you have to expand `auto` for this for-loop? Since we taught the
compiler of the type of `Mid` above, it seems trivial to deduce the type in
this context.
SymbolBody *B = I->first;
> size_t StrOff = I->second;
> Symbols.push_back({B, StrOff, hashGnu(B->getName())});
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160706/1dea1a89/attachment.html>
More information about the llvm-commits
mailing list