Closed Bug 1358169 Opened 8 years ago Closed 8 years ago

mfbt/Span.h compile error with MSVC2017

Categories

(Core :: MFBT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: ted, Assigned: away)

References

Details

Attachments

(1 file)

It looks like Span.h (added in bug 1295611) doesn't compile with Visual C++ 2017:
 1:42.96 Unified_cpp_mfbt_tests_gtest0.cpp
 1:42.96 c:\build\debug-mozilla-central\dist\include\mozilla/Span.h(293): error C3615: constexpr function 'mozilla::span_details::operator >' cannot result in a constant expression
 1:42.96 c:\build\debug-mozilla-central\dist\include\mozilla/Span.h(296): note: failure was caused by call of undefined function or one not declared 'constexpr'
 1:42.96 c:\build\debug-mozilla-central\dist\include\mozilla/Span.h(296): note: see usage of 'mozilla::span_details::span_iterator<mozilla::Span<T,18446744073709551615>,true>::operator <'
 1:42.96         with
 1:42.96         [
 1:42.96             T=int
 1:42.96         ]
 1:42.96 c:\build\debug-mozilla-central\dist\include\mozilla/Span.h(295): note: while compiling class template member function 'bool mozilla::span_details::operator >(const mozilla::span_details::span_iterator<mozilla::Span<T,18446744073709551615>,true> &,const mozilla::span_details::span_iterator<mozilla::Span<T,18446744073709551615>,true> &)'
 1:42.96         with
 1:42.96         [
 1:42.96             T=int
 1:42.96         ]
 1:42.96 c:/build/mozilla-central/mfbt/tests/gtest/TestSpan.cpp(1508): note: see reference to class template instantiation 'mozilla::span_details::span_iterator<mozilla::Span<T,18446744073709551615>,true>' being compiled
 1:42.97         with
 1:42.97         [
 1:42.97             T=int
 1:42.97         ]
 1:42.97
 1:42.98 In the directory  /c/build/debug-mozilla-central/mfbt/tests/gtest
 1:42.98 The following command failed to execute properly:
 1:42.98 c:/build/debug-mozilla-central/_virtualenv/Scripts/python.exe -m mozbuild.action.cl cl.exe -FoUnified_cpp_mfbt_tests_gtest0.obj -c -Ic:/build/debug-mozilla-central/dist/stl_wrappers -DDEBUG=1 -DTRACING=1 -DSTATIC_EXPORTABLE_JS_API -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -Ic:/build/mozilla-central/mfbt/tests/gtest -Ic:/build/debug-mozilla-central/mfbt/tests/gtest -Ic:/build/debug-mozilla-central/dist/include -Ic:/build/debug-mozilla-central/dist/include/nspr -Ic:/build/debug-mozilla-central/dist/include/nss -MD -FI c:/build/debug-mozilla-central/mozilla-config.h -DMOZILLA_CLIENT -TP -nologo -wd5026 -wd5027 -Zc:sizedDealloc- -wd4091 -wd4577 -D_HAS_EXCEPTIONS=0 -W3 -Gy -Zc:inline -utf-8 -Gw -wd4251 -wd4244 -wd4267 -wd4800 -wd4595 -we4553 -GR- -Zi -Oy- -Fdgenerated.pdb -FS c:/build/debug-mozilla-central/mfbt/tests/gtest/Unified_cpp_mfbt_tests_gtest0.cpp
 1:42.99 c:/build/mozilla-central/config/rules.mk:1022: recipe for target 'Unified_cpp_mfbt_tests_gtest0.obj' failed
 1:42.99 mozmake.EXE[5]: *** [Unified_cpp_mfbt_tests_gtest0.obj] Error 1


I have a local patch to make configure detect VC2017, but presumably you could get the same result by invoking vcvars.bat and then MozillaBuild's start-shell.bat and building.
Ah, yes, so this is because the operator> overload:

https://dxr.mozilla.org/mozilla-central/source/mfbt/Span.h#293

calls the non-constexpr operator<:

https://dxr.mozilla.org/mozilla-central/source/mfbt/Span.h#280

and we don't see this with MSVC 2015 because I think:

https://dxr.mozilla.org/mozilla-central/source/mfbt/Span.h#56

disables constexpr for MSVC 2015.

I would be OK with a bandaid patch that disables it for 2017 as well; we can investigate making everything properly constexpr after we get the 2017 support sorted, and constexpr support is not going to be a huge issue for a lot of these Span methods.  Want to write that patch?
Flags: needinfo?(ted)
dmajor was going to look at this, actually. Once we get this fixed I'll look at standing up VS2017 builds in CI.
Assignee: nobody → dmajor
Flags: needinfo?(ted)
Attached patch vs2017spanSplinter Review
Attachment #8860113 - Flags: review?(nfroyd)
Comment on attachment 8860113 [details] [diff] [review]
vs2017span

Review of attachment 8860113 [details] [diff] [review]:
-----------------------------------------------------------------

If this compiles successfully for you on 2017, and works on Try, then r=me.
Attachment #8860113 - Flags: review?(nfroyd) → review+
Pushed by dmajor@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/437cd83fbcb0
Fix Span.h constexprs for VS2017. r=froydnj
https://hg.mozilla.org/mozilla-central/rev/437cd83fbcb0
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: