[PATCH] handle std::byte in -Wclass-memaccess (PR 94923)

Martin Sebor msebor@gmail.com
Tue May 19 19:35:36 GMT 2020


On 5/18/20 3:04 PM, Jason Merrill wrote:
> On 5/8/20 2:16 PM, Martin Sebor wrote:
>> -Wclass-memaccess is suppressed for write accesses to trivially
>> copyable but otherwise nontrivial class types by character types
>> but the suppression neglects to consider the equivalent accesses
>> by std::byte.  The attached patch extends the same privilege also
>> to it.
>>
>> I couldn't find a utility function to check if a type is one of
>> the four "special" byte types so I added one.  If there already
>> isn't one hiding somewhere and this type of a query is done in
>> other places maybe the function should be moved to cp-tree.h.
>>
>> Rather than adding a new test I extended the existing one that
>> has all the infrastructure in place to comprehensively exercise
>> this (maybe even overly so).
> 
>> +/* Returns true if TYPE is a character type of std::byte.  */
> 
> "or"
> 
> Let's name the new function is_byte_access_type to clarify that it 
> doesn't just mean std::byte.
> 
> Let's use the new function in build_cplus_array_type in the initializer 
> of "typeless_storage".
> 
> OK with those changes.

I (finally) committed it in r11-499.

Martin


More information about the Gcc-patches mailing list