Mercury Bugs - mercury
View Issue Details
0000039mercuryBugpublic2008-01-22 17:482009-11-27 02:03
Reporterwangp 
Assigned Towangp 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000039: gcc 4.1.2 on x86-64 miscompiles computed gotos
DescriptionIn compiler/purity.m we needed a work around to avoid a segfault while purity checking invalid/purity/purity.m.
We get a segfault when jumping to the `unnecessary_promise_pure' branch.

Happens with gcc 4.1.2 on x86-64, at gcc -O1 and above.
Additional InformationThis also works around the problem. Note the volatile.

#define MR_COMPUTED_GOTO(val, labels) \
        { \
                static MR_Code *jump_table[] = { \
                        labels \
                }; \
                volatile int val1 = (val); \
                MR_GOTO(jump_table[val1]); \
        }
TagsNo tags attached.
related to 0000066resolved wangp gcc 4.2 incompatibility 
Attached Files

Notes
(0000190)
pbone   
2009-09-26 06:24   
Julian suggested I look at this, saying it might be related to bug66.

It looks like there's a more general problem, GCC 4.x and in particular 4.3 loads addresses into registers in the prelude of a function and then dereferences the register later in the function.

I'm trying to solve the more general problem,

Issue History
2008-01-22 17:48wangpNew Issue
2009-09-26 06:24pboneNote Added: 0000190
2009-09-26 06:26pboneRelationship addedrelated to 0000066
2009-11-24 00:18wangpStatusnew => assigned
2009-11-24 00:18wangpAssigned To => wangp
2009-11-27 02:03wangpStatusassigned => resolved
2009-11-27 02:03wangpResolutionopen => fixed