PSA: Gecko now uses C++20

63 views
Skip to first unread message

Emilio Cobos Álvarez

unread,
Nov 12, 2025, 1:47:14 PM (7 days ago) Nov 12
to dev-pl...@mozilla.org
Hi,

As of bug 176811, we now use C++20 for all our C++ code.

That means you should be able to do things like initializing your bitfields inline now, along with a lot of other language features :)

There are probably also some follow-up opportunities:
  • I think some of the `FMT_STRING` clunkiness could be cleaned up.
  • MOZ_LIKELY / MOZ_UNLIKELY could be moved to the standard `[[likely]]` and `[[unlikely]]` macros.
  • Tons of constexpr stuff could be improved.
  • Maybe std::span could be used instead of mozilla::Span.
And probably tons of others I'm missing.

Anyways, this took a surprising amount of work, see the bug for details. Chris Peterson did most of it (thanks!), I just pushed it over the finish line. Thanks to everyone else who helped too (and to Mike for all the reviews as usual :P).

Cheers,
 -- Emilio

Emilio Cobos Álvarez

unread,
Nov 12, 2025, 1:50:59 PM (7 days ago) Nov 12
to dev-pl...@mozilla.org
On Thu, Nov 13, 2025 at 3:46 AM Emilio Cobos Álvarez <emi...@mozilla.com> wrote:
Hi,

As of bug 176811, we now use C++20 for all our C++ code.

Err, of course that should've said bug 1768116, sorry about that.

Andrew McCreight

unread,
Nov 12, 2025, 4:00:02 PM (7 days ago) Nov 12
to dev-pl...@mozilla.org
On Wed, Nov 12, 2025 at 10:47 AM 'Emilio Cobos Álvarez' via dev-pl...@mozilla.org <dev-pl...@mozilla.org> wrote:
Hi,

As of bug 176811, we now use C++20 for all our C++ code.

That means you should be able to do things like initializing your bitfields inline now, along with a lot of other language features :)

There are probably also some follow-up opportunities:
  • I think some of the `FMT_STRING` clunkiness could be cleaned up.
  • MOZ_LIKELY / MOZ_UNLIKELY could be moved to the standard `[[likely]]` and `[[unlikely]]` macros.
  • Tons of constexpr stuff could be improved.
  • Maybe std::span could be used instead of mozilla::Span.

Keep in mind that std::span currently does not do bounds checking while mozilla:Span does, so you are potentially introducing security problems if you make this substitution. (If you'd like to help change that, please take a look at some of the bugs blocking bug 1986488!)

Andrew
 
And probably tons of others I'm missing.

Anyways, this took a surprising amount of work, see the bug for details. Chris Peterson did most of it (thanks!), I just pushed it over the finish line. Thanks to everyone else who helped too (and to Mike for all the reviews as usual :P).

Cheers,
 -- Emilio

--
You received this message because you are subscribed to the Google Groups "dev-pl...@mozilla.org" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dev-platform...@mozilla.org.
To view this discussion visit https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/CAFhp-qfYGNhpAJ%2B%2BOfgvxszKp7B_fZkQQv9suOOUxwKGcLUViA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages