Mercury Bugs - mercury | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0000382 | mercury | Bug | public | 2015-03-15 00:22 | 2015-03-16 03:15 |
Reporter | pbone | ||||
---|---|---|---|---|---|
Assigned To | zs | ||||
Priority | normal | Severity | crash | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | x86_64 | OS | Debian | OS Version | 8.0 |
Product Version | |||||
Target Version | Fixed in Version | ||||
Summary | 0000382: arg-pack-bits optimisation broken with foreign_enums. | ||||
Description | The arg-pack-bits optimisation is incorrectly applied to members of structures which are foreign enums. In this example I have two types each has two fields and therefore could be stored in 1 bit each. However they are foreign enums and in this case may contain values that may use an arbitrary number of bits. Mercury incorrectly assumes that they use fewer bits and attempts to pack them. | ||||
Steps To Reproduce | Code that uses the following structure is mis-compiled. I'm attaching a full example. Note that the 3rd field is necessary to trigger the crash. :- type addrinfo ---> addrinfo( ai_family :: family, ai_socktype :: socktype, ai_protocol :: protocol_num ). :- type family ---> fam_inet ; fam_inet6. :- type socktype ---> sock_stream ; sock_dgram. :- pragma foreign_enum("C", family/0, [fam_inet - "AF_INET", fam_inet6 - "AF_INET6"]). :- pragma foreign_enum("C", socktype/0, [sock_stream - "SOCK_STREAM", sock_dgram - "SOCK_DGRAM"]). The error goes away when I set --arg-pack-bits=0 | ||||
Additional Information | Note that the solution will need to be aware of cases where the foreign enum is in the implementation section of a different module. | ||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | bug_pack_bits.m (2,542) 2015-03-15 00:22 https://bugs.mercurylang.org/file_download.php?file_id=239&type=bug |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
Issue History | |||||
Date Modified | Username | Field | Change | ||
---|---|---|---|---|---|
2015-03-15 00:22 | pbone | New Issue | |||
2015-03-15 00:22 | pbone | File Added: bug_pack_bits.m | |||
2015-03-15 01:10 | zs | Assigned To | => zs | ||
2015-03-15 01:10 | zs | Status | new => assigned | ||
2015-03-15 04:31 | zs | Note Added: 0000817 | |||
2015-03-15 10:06 | pbone | Note Added: 0000818 | |||
2015-03-16 03:15 | zs | Note Added: 0000819 | |||
2015-03-16 03:15 | zs | Status | assigned => resolved | ||
2015-03-16 03:15 | zs | Resolution | open => fixed |