Hi Ben,

On Thu, 2025-11-06 at 11:34 -0800, Ben Woodard via Dwarf-discuss wrote:
> On 11/6/25 9:46 AM, Mark Wielaard via Dwarf-discuss wrote:
> 
> Given what I now know and the problem that you pointed out with CFI.
> I think that I would suggest: 
> 
> Rename DW_OP_mod to DW_OP_rem in DWARF6 and then specify that it uses
> truncated division so that it follows the semantics of C99's % operator
> for signed and unsigned types. This would minimize the implementation
> difficulty for most consumers. This should be backward compatible with
> existing usage because of the undocumented limitation on the domain of
> DW_OP_mod. If people feel there is a need, it can also be extended to
> support floating point types.  
> 
> Then if the committee feels that it is useful to have a true modulo function,
> they could also add a DW_OP_modulo which uses floored division from Knuth.

I think renaming is really confusing. And I think extending to
supporting floating point types should be a separate issue that would
also look at the other operators.

Maybe a compromise would be to keep DW_OP_mod (and make DW_OP_rem an
alias?) which is only defined for use with (unsigned) generic type
values. Then introduce new DW_OP_modulo (defined using floored
division) and DW_OP_remainder (defined using truncated division)
operators that are only to be used with typed DWARF stack values?

Cheers,

Mark
-- 
Dwarf-discuss mailing list
[email protected]
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss

Reply via email to