[webkit-dev] Use of [[maybe_unused]]

Alex Christensen achristensen at apple.com
Tue Jan 14 15:48:29 PST 2020

I think that would still use 1 extra byte per object, which isn’t ideal but we may be ok with that.

In general [[maybe_unused]] tells the compiler to stop telling us about potential speedups.  Usually that speedup is just a value in a register or on the stack, which has a relatively small cost, but sometimes it can be a large cost if it’s using lots of memory.  We may choose that’s ok.

> On Jan 14, 2020, at 11:55 AM, Suzuki, Basuke <Basuke.Suzuki at sony.com> wrote:
>>> `sessionID` is used in RELEASE_LOG_IF_ALLOWED() and we have empty
>>> implementation of RELEASE_LOG() so that it's ended up with unused
>>> parameter warning of sessionID. We can add UNUSED_PARAM(sessionID) in
>>> this case, but [[maybe_unused]] is more correct choice to describe the code
>>> because sessionID is actually used.
>> In this case you could use RELEASE_LOG_DISABLED but I agree
>> [[maybe_unused]] would be better.  I’m ok with it as long as all the ports are
>> OK with it, including support in their oldest supported compiler.
> Got it. I'll try sending to EWS to see it works for every ports. 
>> I think it would be better to put #if PLATFORM(COCOA) around member
>> variables like this because I don’t think [[maybe_unused]] will remove the
>> additional byte in the structure.  Otherwise we’re just wasting memory.
> Let us think about the cost to maintain platform dependent implementation of this class.
> Because the member variable is assigned in constructor, we have to make platform dependent
> Constructor which is usually hard to maintain and want to away from that if possible.
> How about this?
> template <typename T> struct Unused { explicit Empty(T) { } };	
> bool m_isHTTPSCheckEnabled;
> #else
> [[maybe_unused]] Unused<bool> m_isHTTPSCheckEnabled;
> #endif
> -----
> Basuke Suzuki
> SONY PlayStation

More information about the webkit-dev mailing list