potential bug in pv_subtract in prologue-value.c

CF Bolz-Tereick via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
Hi all!

this is pretty random, but I was reading some code in prologue-value.c
out of curiosity, and spotted something that looked rather
suspicious/buggy to me. isn't the call to constant_last in pv_subtract
wrong? constant_last potentially swaps the arguments of pv_subtract,
which looks wrong, because subtraction is not commutative:

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/prologue-value.c;h=13bf4362069e99301dba7d99f039f547768b264d;hb=HEAD#l128

This is of course a very theoretical bug, I would suspect it's pretty
hard to demonstrate this problem in any "real" machine code that is
thrown at prologue analysis on one of the platforms that uses it. but
I'd be happy to write a patch with a fix and a unit test if somebody
else finds it weird too.

Cheers,

CF
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.