--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAJTZ7L%2BpxUZnouwo%3DOLzLNqaN4z_gp13Z5Xao9LPk6YuNE%2BUpQ%40mail.gmail.com.
--
"It depends". Chromium is written in C++, so we should broadly aim to write in C++-as-spec'd. Several things we rely on heavily aren't covered by the language spec though (e.g. the whole _EXPORT macro business), and it's ok to use "progressively enhancing" features via a macro that is defined to nothing for other compilers (e.g. WARN_UNUSED_RESULT or the other stuff in base/compiler_specific.h; ASan; etc).
Number of static initializers for compile-time-evaluatable things are a quality-of-implementation thing. There are two problems in general with static initializers: 1. they have undefined order they run in 2. they can slow down startup. For compile-time evaluatable initializers, 1 is probably not an issue, so this is only a perf thing. For perf, we should only care about the configuration we ship (e.g. we wouldn't mind about debug builds).Now, we currently still ship an MSVC build clang to some users, so for now I think the answer is we can't rely on this specific thing just yet. But once we ship only clang-built chromes to Windows users, I think it's fine to rely on this specific thing, for the reasons mentioned above.
--On Thu, Feb 1, 2018 at 6:48 AM, Gabriel Charette <g...@chromium.org> wrote:Hello folks,--I have this internal debate with myself and would like your take.Should we use clang-only features that are slightly better versions of the actual C++ spec?e.g. :clang doesn't generate static initializers for globals whose type is constexpr-default-constructible.MSVC does -- we just found out.The spec is vague on this, i.e. doesn't require that no initializer be generated. But, in Bjarne Stroustrup's words : I would hope that no self-respecting compiler would miss the optimization opportunity to do what I originally said: "A constexpr function is evaluated at compile time if all its arguments are constant expressions.".With clang we have -Wglobal-constructors (now active in //base) that would throw if the compiler generated a static initializer.I was also hoping to experiment with the [[clang::require_constant_initialization]] attribute (requires constant initialization without requiring constexpr -- useful for constexpr default constructible globals that then don't want to remain const).Using these would allow us to get rid of much usage of LazyInstance, replacing it by compile-time initialization. Since we know LazyInstance initialization is somewhat costly (and sometimes problematic), reducing its usage would be great!We have everything it takes to put this in place, but we need to use clang specific features to go beyond the C++ spec. Such features are apparently not supported by MSVC (should we even care?!).Thanks!Gab
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAJTZ7L%2BpxUZnouwo%3DOLzLNqaN4z_gp13Z5Xao9LPk6YuNE%2BUpQ%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAMGbLiFFzVXsdxDOicceK5tyUjdqX_SYCipD2sY6LrXierdq-g%40mail.gmail.com.
On 1 February 2018 at 13:34, Nico Weber <tha...@chromium.org> wrote:"It depends". Chromium is written in C++, so we should broadly aim to write in C++-as-spec'd. Several things we rely on heavily aren't covered by the language spec though (e.g. the whole _EXPORT macro business), and it's ok to use "progressively enhancing" features via a macro that is defined to nothing for other compilers (e.g. WARN_UNUSED_RESULT or the other stuff in base/compiler_specific.h; ASan; etc).
Number of static initializers for compile-time-evaluatable things are a quality-of-implementation thing. There are two problems in general with static initializers: 1. they have undefined order they run in 2. they can slow down startup. For compile-time evaluatable initializers, 1 is probably not an issue, so this is only a perf thing. For perf, we should only care about the configuration we ship (e.g. we wouldn't mind about debug builds).Now, we currently still ship an MSVC build clang to some users, so for now I think the answer is we can't rely on this specific thing just yet. But once we ship only clang-built chromes to Windows users, I think it's fine to rely on this specific thing, for the reasons mentioned above.How's that effort going btw, is there a timeline?
Number of static initializers for compile-time-evaluatable things are a quality-of-implementation thing. There are two problems in general with static initializers: 1. they have undefined order they run in 2. they can slow down startup. For compile-time evaluatable initializers, 1 is probably not an issue, so this is only a perf thing. For perf, we should only care about the configuration we ship (e.g. we wouldn't mind about debug builds).Now, we currently still ship an MSVC build clang to some users, so for now I think the answer is we can't rely on this specific thing just yet. But once we ship only clang-built chromes to Windows users, I think it's fine to rely on this specific thing, for the reasons mentioned above.