Closed Bug 764616 Opened 12 years ago Closed 12 years ago

platform.h: In constructor ‘Sampler::Sampler(int, bool)’: warning: ‘Sampler::active_’ will be initialized after ... Atomic32 Sampler::paused_’ ... when initialized here [-Wreorder]

Categories

(Core :: Gecko Profiler, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla16

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

(Whiteboard: [build_warning])

Attachments

(1 file)

../../../mozilla/tools/profiler/platform.h: In constructor ‘Sampler::Sampler(int, bool)’:
../../../mozilla/tools/profiler/platform.h:237:12: warning: ‘Sampler::active_’ will be initialized after [-Wreorder]
../../../mozilla/tools/profiler/platform.h:236:12: warning:   ‘Atomic32 Sampler::paused_’ [-Wreorder]
../../../mozilla/tools/profiler/platform-linux.cc:182:1: warning:   when initialized here [-Wreorder]

Looks like http://hg.mozilla.org/mozilla-central/rev/fdea12fb0063 added "paused_" to the constructor init lists in the wrong order. (after active_, instead of before active_)
Attached patch fixSplinter Review
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #632926 - Flags: review?(bgirard)
Comment on attachment 632926 [details] [diff] [review]
fix

It pains me that compiler complain about this.
Attachment #632926 - Flags: review?(bgirard) → review+
Yeah. :) (It really only matters when the init list is invoking actual constructors and functions (instead of just initializing a boolean value) -- then, it's more important so that it's clear which functions actually get invoked first.)

Thanks for the review! Pushed to m-i:
  https://hg.mozilla.org/integration/mozilla-inbound/rev/669274e1fcf7
OS: Linux → All
Hardware: x86_64 → All
Target Milestone: --- → mozilla16
(In reply to Daniel Holbert [:dholbert] from comment #3)
> Yeah. :) (It really only matters when the init list is invoking actual
> constructors and functions (instead of just initializing a boolean value) --
> then, it's more important so that it's clear which functions actually get
> invoked first.)

IIRC even in that case the compiler will generate code to initialize the members in the order they're declared in the class.  This warning is only useful to tell the developer that the order in which they initialize class members in the definition of the constructor actually doesn't matter.  I also agree that warning this for POD types is a waste of everybody's time, and for the case where the initialization has side effects, the compiler can probably pick a better warning message!
Whiteboard: [build_warning]
(In reply to Ehsan Akhgari [:ehsan] from comment #4)
> IIRC even in that case the compiler will generate code to initialize the
> members in the order they're declared in the class.

(Correct -- that's what I meant, sorry if it wasn't clear.)
Thanks for the clarification ^-^.
https://hg.mozilla.org/mozilla-central/rev/669274e1fcf7
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: