View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
---|---|---|---|---|---|---|---|---|---|
0000240 | mercury | Bug | public | 2011-12-02 20:08 | 2011-12-09 10:26 | ||||
Reporter | maclarty | ||||||||
Assigned To | wangp | ||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | resolved | Resolution | fixed | ||||||
Product Version | |||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0000240: float unboxing issue on MinGW | ||||||||
Description | The attached program produces incorrect output when compiled on MinGW with rotd-2011-11-29 in grade hlc.gc at -O1 or lower: $ mmc bug.m -O1 --grade hlc.gc $ ./bug 0.0 123.0 $ mmc bug.m -O2 --grade hlc.gc $ ./bug 123.0 123.0 $ uname -a MINGW32_NT-6.1 TTT 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys $ gcc --version gcc.exe (GCC) 4.6.1 11.07-beta-2011-11-30 works. | ||||||||
Tags | No tags attached. | ||||||||
Attached Files |
|
Notes | |
juliensf (administrator) 2011-12-02 20:53 |
Hi, Does the same also occur with the asm_fast.gc grade on MinGW? Does the same occur on other non-Windows 32-bit machines. (If the problem is not restricted to MinGW then it's probably an issue to related to Peter's changes for unboxed doubles, since that didn't go onto the 11.07 branch.) |
2011-12-02 21:40 |
The problem does not occur with asm_fast.gc or 32bit Linux. I also compared the c file generated on Linux and Windows and there are no differences. Note that I used a different version of gcc on Linux (4.4.3). |
juliensf (administrator) 2011-12-02 21:49 |
I have MinGW gcc 4.5.0 on my laptop so I will give that a try. We should try 4.6.1 on Linux or Mac OS X. |
juliensf (administrator) 2011-12-03 04:58 |
It also occurs with gcc 4.5.0 on MinGW. |
juliensf (administrator) 2011-12-03 05:03 |
-O[01] --common-struct works -O1 --inline-simple causes both values to be printed incorrectly. |
2011-12-03 11:59 |
I believe the cause of the problem is some incorrect assumptions about how struct fields are aligned. Consider the following C program: #include <stdio.h> struct t { void *f1; double f2; }; int main() { printf("%p\n", &((struct t*)0)->f2); } On MinGW this produces 8, but on 32 bit Linux it produces 4. In the C code generated for bug.m there is the following struct: struct bug_scalar_cell_group_1 { MR_Box f1; MR_Float f2; }; Later on we use MR_hl_field to extract the float field. However MR_hl_field casts the struct to an array of pointers and then looks up element 1. That would look at offset 4, but on MinGW, the float field is at offset 8. |
wangp (developer) 2011-12-03 12:36 |
That'd be it, thanks. See also bug 0000211 |
wangp (developer) 2011-12-09 10:25 |
Fix committed. |
Issue History | |||
Date Modified | Username | Field | Change |
---|---|---|---|
2011-12-02 20:08 |
|
New Issue | |
2011-12-02 20:08 |
|
File Added: bug.m | |
2011-12-02 20:53 | juliensf | Note Added: 0000422 | |
2011-12-02 20:53 | juliensf | Status | new => feedback |
2011-12-02 21:40 |
|
Note Added: 0000423 | |
2011-12-02 21:49 | juliensf | Note Added: 0000424 | |
2011-12-03 04:58 | juliensf | Note Added: 0000425 | |
2011-12-03 05:03 | juliensf | Note Added: 0000427 | |
2011-12-03 11:59 |
|
Note Added: 0000428 | |
2011-12-03 12:36 | wangp | Note Added: 0000429 | |
2011-12-05 11:00 | wangp | Status | feedback => assigned |
2011-12-05 11:00 | wangp | Assigned To | => wangp |
2011-12-09 10:25 | wangp | Note Added: 0000435 | |
2011-12-09 10:26 | wangp | Status | assigned => resolved |
2011-12-09 10:26 | wangp | Resolution | open => fixed |