[llvm] 0a4c946 - Fix MSVC warning "all return expressions must deduce to the same type"

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 00:17:51 PDT 2022


There's a later `return 0ul` that MSVC wouldn't reconcile to a type 
compatible with uintptr_t, but was happy if we provided the explicit 
lambda return type.

On 19/09/2022 22:55, David Blaikie wrote:
> any idea what problem MSVC actually had?
>
> On Mon, Sep 19, 2022 at 8:01 AM Simon Pilgrim via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: Simon Pilgrim
>> Date: 2022-09-19T16:00:48+01:00
>> New Revision: 0a4c946abcfaae3601c49a55e29944287f867b7f
>>
>> URL: https://github.com/llvm/llvm-project/commit/0a4c946abcfaae3601c49a55e29944287f867b7f
>> DIFF: https://github.com/llvm/llvm-project/commit/0a4c946abcfaae3601c49a55e29944287f867b7f.diff
>>
>> LOG: Fix MSVC warning "all return expressions must deduce to the same type"
>>
>> Added:
>>
>>
>> Modified:
>>      llvm/lib/Object/XCOFFObjectFile.cpp
>>
>> Removed:
>>
>>
>>
>> ################################################################################
>> diff  --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp
>> index b1f44f1db667..853201283bf6 100644
>> --- a/llvm/lib/Object/XCOFFObjectFile.cpp
>> +++ b/llvm/lib/Object/XCOFFObjectFile.cpp
>> @@ -798,7 +798,7 @@ Expected<DataRefImpl> XCOFFObjectFile::getSectionByNum(int16_t Num) const {
>>   DataRefImpl
>>   XCOFFObjectFile::getSectionByType(XCOFF::SectionTypeFlags SectType) const {
>>     DataRefImpl DRI;
>> -  auto GetSectionAddr = [&](const auto &Sections) {
>> +  auto GetSectionAddr = [&](const auto &Sections) -> uintptr_t {
>>       for (const auto &Sec : Sections)
>>         if (Sec.getSectionType() == SectType)
>>           return reinterpret_cast<uintptr_t>(&Sec);
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list