This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add a character size parameter to c_strlen/get_range_strlen


On Tue, 21 Aug 2018, Martin Sebor wrote:

> I still believe it would be simpler, more robust, and safe
> to pass in a flag to either count bytes (the default, for
> all callers except sprintf %ls), or elements of the string
> type (for sprintf %ls).

But the correct thing to count for sprintf %ls is elements of the type 
expected by sprintf %ls.  That may not be the type of the string constant 
(and as this is in variable arguments, there isn't any implicit conversion 
to const wchar_t * like you would get with a function prototype - I'm not 
sure if anything ensures this code is only reached, regardless of 
language, if the argument does actually (after any casts present in the 
source code) point to the correct wchar_t type).

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]