On 21/01/17 20:15, Andreas Tobler wrote: > On 21.01.17 00:42, Jakub Jelinek wrote: >> On Fri, Jan 20, 2017 at 01:37:13PM -0700, Jeff Law wrote: >>>>> Which is best will depend on what the front/mid ends might have >>>>> done to >>>>> apply the documented limit. >>>> >>>> Here I know not enough to give a decision. In tree the priority_type is >>>> unsigned short. In varasm priority is an int. >>>> >>>> Similar functions, like arm_elf_asm_cdtor, do use the sprintf >>>> instead of >>>> snprintf. They theoretically have the same issue. >>>> >>>> So, either: >>>> 2.) use %.5hu in snprintf >>>> or >>>> 3.) cast priority in snprintf to (unsigned short) >>> I'd go with #2. I think #3 still requires range propagation to avoid >>> the >>> false positive. >> >> I actually think 1.) is best work-around, after 18 bytes there will be >> some >> padding so 23 bytes will almost always eat the same amount of stack >> space, >> and we avoid actually adding some instruction to cast it or hoping all >> the >> libcs we run on support %.5hu properly. > > Richard, what do you think about this suggestion? > > Thanks, > Andreas >
I'm happy to go with that, but please add a comment as well, or some well meaning individual may accidentally reverse the change after counting the bytes... R.