This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Pointer parameter in function optimized out - incorrectly
- From: Kalle Olavi Niemitalo <kon at iki dot fi>
- To: James Kuyper <James dot R dot Kuyper at NASA dot gov>
- Cc: <gcc-help at gcc dot gnu dot org>, <jameskuyper at verizon dot net>
- Date: Sat, 15 Aug 2015 23:39:09 +0300
- Subject: Re: Pointer parameter in function optimized out - incorrectly
- Authentication-results: sourceware.org; auth=none
- References: <55CF90B7 dot 70201 at NASA dot gov>
James Kuyper <James.R.Kuyper@NASA.gov> writes:
> At optimization level 2, as indicated by the following output from gdb,
> scan_time is optimized out of the function call interface for
> process_a_scan(). The address for SD_start_time is simply
> passed directly to compute_SD_start_time(). The problem is that it is
> sometimes the incorrect address. In this particular case, 33 scans were
> processed without a hitch, and then it failed for the 34th:
IIRC, "<value optimized out>" can mean that the value was passed
to the function with the usual mechanism, but the function no
longer needs it at that point, so the compiler has reused the
register or memory location for some other purpose.
I am thus not convinced that any link-time optimization occurred.
Can you reproduce the SIGSEGV with the same input?
If so, you could try breaking at the 34th entry to process_a_scan
and checking whether the pointer is correct at that time.
If you have a buffer overflow or underflow that corrupts the
pointer in memory, then you might be able to track that down with
a watchpoint in GDB, perhaps coupled with breakpoints that run
commands to set the watchpoint on entry to a function and remove
it again when the function is about to return.