Closed Bug 1603371 Opened 4 years ago Closed 4 years ago

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

Categories

(Core :: JavaScript Engine, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla73
Tracking Status
firefox-esr68 --- unaffected
firefox71 --- unaffected
firefox72 --- unaffected
firefox73 --- fixed

People

(Reporter: ricotz, Assigned: Sylvestre)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0

Steps to reproduce:

Building on Ubuntu with clang 9 and libstdc++ 6 (gcc 8.3.0 and 9.2.1) results in the exact failure claimed to be fixed in https://bugzilla.mozilla.org/show_bug.cgi?id=1601907

Actual results:

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

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

Expected results:

Reverting https://hg.mozilla.org/mozilla-central/rev/c1db977cabfe fixed the failure.

Regressed by: 1601907

That's weird...

What does GCC 9's bits/char_traits.h and bits/c++config.h look like?

Apparently we should be using _GLIBCXX_RELEASE, which corresponds to the GCC version that owns the headers. But I still don't understand why the compilation is failing, because GCC 9's headers declare char_traits<T>::length as constexpr.

Flags: needinfo?(sledru)
Priority: -- → P2
Priority: P2 → P1
Assignee: nobody → sledru
Pushed by sledru@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2ba741910e8f
Use _GLIBCXX_RELEASE instead of __GLIBCXX__ r=froydnj
Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla73

Rico, are we good now ?
thanks

Flags: needinfo?(sledru) → needinfo?(ricotz)

(In reply to Sylvestre Ledru [:Sylvestre] from comment #7)

Rico, are we good now ?
thanks

No, still failing the same way

Flags: needinfo?(ricotz)
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: