Closed Bug 1601907 Opened 5 years ago Closed 5 years ago

non-constexpr function 'length' cannot be used in a constant expression

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla73
Tracking Status
firefox73 --- fixed

People

(Reporter: Sylvestre, Assigned: Sylvestre)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Building with clang trunk

 /var/lib/jenkins/workspace/firefox-clang-last/js/src/builtin/intl/NumberFormat.cpp:403:25: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
 static constexpr size_t MaxUnitLength() {
                         ^
 /var/lib/jenkins/workspace/firefox-clang-last/js/src/builtin/intl/NumberFormat.cpp:408:31: note: non-constexpr function 'length' cannot be used in a constant expression
     length = std::max(length, std::char_traits<char>::length(unit.subtype));
                               ^
 /usr/bin/../lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/bits/char_traits.h:266:7: note: declared here
       length(const char_type* __s)
       ^
 In file included from Unified_cpp_js_src5.cpp:2:
 /var/lib/jenkins/workspace/firefox-clang-last/js/src/builtin/intl/NumberFormat.cpp:419:18: error: variable-sized object may not be initialized
   char unitChars[MaxUnitLength() + 1] = {};
                  ^~~~~~~~~~~~~~~~~~~
 2 errors generated.

Maybe caused by the C++17 migration?
with clang version 10.0.0-+20191205115126+41eeded8043-1exp120191205105719.1634

This is because GCC 6.x's libstdc++ is not C++17 conformant. We could just disable the constexpr code path here (I have a local patch to do just that).

Assignee: nobody → sledru
Pushed by sledru@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c1db977cabfe Disable a code path when built with libstdc++ 6 and below r=froydnj
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla73

This change actually causes the mentioned build failure on Ubuntu with clang 9 and libstdc++ 6 (gcc 8.3.0 and 9.2.1)

https://launchpadlibrarian.net/455261494/buildlog_ubuntu-focal-amd64.firefox-trunk_73.0~a1~hg20191211r506473-0ubuntu0.20.04.1~umd1_BUILDING.txt.gz

Building with clang 8 and libstdc++6 (gcc 5.4.0) seems to be not affected.

(In reply to Rico Tzschichholz from comment #5)

This change actually causes the mentioned build failure on Ubuntu with clang 9 and libstdc++ 6 (gcc 8.3.0 and 9.2.1)

could you please open a new bug for this?
thanks

Regressions: 1603371
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: