runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Remove redundant initialization to keep consistent style

Open AaronRobinsonMSFT opened this issue 3 years ago • 1 comments

In https://github.com/dotnet/runtime/pull/74363, an inconsistency was introduced in gc.cpp with respect to initialization. This inconsistency is related to use of {} vs memset. This was done to remove UB with using memset on non-trivial types, in this case containing a user defined constructor. This introduced a regression due to how some constructors were defined, but also introduced inconsistent style. We should remove this inconsistency since these fields are static anyways and will be properly initialized during library load.

    memset (full_gc_counts, 0, sizeof (full_gc_counts));

    last_ephemeral_gc_info = {};
    last_full_blocking_gc_info = {};
#ifdef BACKGROUND_GC
    memset (&last_bgc_info, 0, sizeof (last_bgc_info));
#endif //BACKGROUND_GC

/cc @dotnet/gc

AaronRobinsonMSFT avatar Sep 20 '22 14:09 AaronRobinsonMSFT

Tagging subscribers to this area: @dotnet/gc See info in area-owners.md if you want to be subscribed.

Issue Details

In https://github.com/dotnet/runtime/pull/74363, an inconsistency was introduced in gc.cpp with respect to initialization. This inconsistency is related to use of {} vs memset. This was done to remove UB with using memset on non-trivial types, in this case containing a user defined constructor. This introduced a regression due to how some constructors were defined, but also introduced inconsistent style. We should remove this inconsistency since these fields are static anyways and will be properly initialized during library load.

    memset (full_gc_counts, 0, sizeof (full_gc_counts));

    last_ephemeral_gc_info = {};
    last_full_blocking_gc_info = {};
#ifdef BACKGROUND_GC
    memset (&last_bgc_info, 0, sizeof (last_bgc_info));
#endif //BACKGROUND_GC

/cc @dotnet/gc

Author: AaronRobinsonMSFT
Assignees: AaronRobinsonMSFT
Labels:

area-GC-coreclr

Milestone: 8.0.0

ghost avatar Sep 20 '22 14:09 ghost