![]() |
![]() |
#1 |
Nov 2003
22·5·373 Posts |
![]()
Here is a code snippet:
Code:
void prepare_bounds(v1, v2, sign) int v1[2], v2[2], sign; { /* start of prepare_bounds */ double m_over_a1, n_over_b1, b0_over_b1, a0_over_a1; double a0, a1, b0, b1, one_over_a1, one_over_b1; double l1and4, l2and3, l1and3, determ, inv_determ; double stime; double temp; temp = get_time(); if (TIME_STATS) stime = get_time(); printf("1"); a0 = (double)v1[0]; a1 = (double)v2[0]; b0 = (double)v1[1]; b1 = (double)v2[1]; printf("2"); using Visual Studio 2010. As written exactly above the code runs just fine. If I delete the "printf("1");" statement, the code core dumps before hitting printf("2"); If I delete the calls to get_time(), the code runs fine. This seems to be the same compiler bug that I saw with VS 2008. Apparently, the code is doing a register mis-allocation involving the call to get_time. Adding the printf("1") statement seems to make the problem go bye-bye..... This is a total mystery. Comments would be GREATLY appreciated. |
![]() |
![]() |
![]() |
#2 | |
Nov 2003
746010 Posts |
![]() Quote:
printf statements, the code runs fine. It also runs fine without the printf's when compiled with Visual C++ 5.0 and Visual C++ 6.0 WTF is going on here???? It is only when I produce a RELEASE version under Vs2010 that the code barfs. |
|
![]() |
![]() |
![]() |
#3 | |
Nov 2003
22·5·373 Posts |
![]() Quote:
the code. It only barfs within this little piece of code. |
|
![]() |
![]() |
![]() |
#4 |
Aug 2002
Buenos Aires, Argentina
32·149 Posts |
![]()
Are you compiling in 32-bit mode? Notice that there are some differences in 64 bits so if you for example cast pointers which are 64 bits long to integer (32 bits) and then you try to use them again as pointers, it will fail.
It is possible that before entering that function the heap and/or the stack were corrupted, so the function get_time() just triggers the error that was already present. |
![]() |
![]() |
![]() |
#5 |
Oct 2007
6916 Posts |
![]()
That's a weird problem.
I assume this is being compiled in 32-bit mode. Instead of printf("1"), try putting an inline asm block that does nothing, like Code:
__asm { nop } Last fiddled with by Robert Holmes on 2010-10-01 at 01:35 |
![]() |
![]() |
![]() |
#6 | |
Sep 2002
Database er0rr
3·11·107 Posts |
![]() Code:
void prepare_bounds(v1, v2, sign) int v1[2], v2[2], sign; Quote:
Looks like you function variable declarations/definitions are old school Last fiddled with by paulunderwood on 2010-10-01 at 01:49 |
|
![]() |
![]() |
![]() |
#7 | ||
Nov 2003
22·5·373 Posts |
![]() Quote:
Quote:
This is a register misallocation. Adding the printf causes the compiler to use its registers differently. |
||
![]() |
![]() |
![]() |
#8 | |
Nov 2003
746010 Posts |
![]() Quote:
|
|
![]() |
![]() |
![]() |
#9 |
Aug 2002
Buenos Aires, Argentina
32×149 Posts |
![]()
Maybe it is a problem on the optimization stage. I suggest you to change the project in order to add debugging information in the RELEASE version, and then run your program until the function is reached. Then run it step by step in the disassembler window. You can see in this way whether the function was compiled correctly or not.
|
![]() |
![]() |
![]() |
#10 | |
Nov 2003
164448 Posts |
![]() Quote:
|
|
![]() |
![]() |
![]() |
#11 | |
Nov 2003
22×5×373 Posts |
![]() Quote:
do_nothing is just a dummy routine the code STILL fails. How can the addition of a printf of a static string cure a core dump caused by a read access failure? |
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
mprime 28.10 compiler warning | Explorer09 | Software | 1 | 2017-01-23 02:50 |
GCC/compiler warnings | Dubslow | Programming | 2 | 2016-02-27 06:55 |
compiler/assembler optimizations possible? | ixfd64 | Software | 7 | 2011-02-25 20:05 |
Linux32 -> Windows64 C compiler? | geoff | Programming | 3 | 2007-09-26 03:09 |
/. Video processor compiler | tha | Hardware | 17 | 2005-10-12 08:10 |