Issue Details (XML | Word | Printable)

Key: PCC-344
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

segmentation fault accessing static struct member, m.b[0]

Created: 09/May/11 09:42 AM   Updated: 10/May/11 09:14 PM
Component/s: Common code
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386

 Description  « Hide
running the following example program

main(int ac, char **av)
        static struct {
                int a;
                char *b;
        } m = { 0, "foo" };

        return m.b[0];

produces a segmentation fault accessing the value of m.b[0]

looking at the assembler it seems that pcc has forgotten to use the offset
of b, or perhaps confused the struct address with the char pointer?

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 10/May/11 09:14 PM
Heh, this bug has always been around since pcc was ported to i386. Actually the code comes from the vax port but it was not affected due to the old way of handling symbol tables.