RISC OS Open
A fast and easily customised operating system for ARM devices
ROOL
Home | News | Downloads | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account

Previous|Next

  • Tickets
  • » Ticket #444

Ticket #444 (Open)Wed Dec 13 18:05:55 UTC 2017

cc 5.72 abort on data transfer with __packed structs

Reported by: Colin (478) Severity: Major
Part: RISC OS: C/C++ toolchain Release:
Milestone: Status Open

Details by Colin (478):

The following code causes an abort on data transfer error. If I remove the __packed keyword it works ok, if I uncomment ‘buf.size = buf.size’ it works ok or if I reverse the nested loop order so that s is outer and i is inner it works ok.

#include <stdint.h>

uint32_t array[] = {100, 200, 300, 400, 500, 600, 700, 800, 900};

#define ARRAYSIZE (sizeof(array) / sizeof(array[0]))

int main(void)
{
    __packed struct 
    {
            uint16_t size;
            struct
            {
                    uint32_t min, max, res;
            } range[ARRAYSIZE];
    } buf;
    
    buf.size = 2;
    
    for (unsigned i = 0; i < buf.size; i++)
    {
        for (int s = 0; s < ARRAYSIZE; s++)
        {
        //    buf.size = buf.size;
            if (array[s] >= buf.range[i].min && array[s] <= buf.range[i].max)
            {
                break;
            }
        }
    }
    return 0;
}

Changelog:

Modified by Sprow (202) Sun, December 17 2017 - 09:19:38 GMT

To clarify: it’s the resulting output code that aborts, not the compiler.
The abort is caused by trying to read a word from a non word aligned offset.

Uncommenting the line mentioned causes an (aligned) LDM to be used instead, so it at least doesn’t abort, but I’m not convinced it’s accounted for the offset of 2 correctly and might well be silently incorrect instead.

Modified by Sprow (202) Fri, December 29 2017 - 12:43:25 GMT

  • Part changed from Unspecified to RISC OS: C/C++ toolchain

  • Comment on, or change status of, this ticket

Previous|Next

Search tickets

Social

Follow us on and

Commercial use

For commercial enquiries, please contact the owners of RISC OS, Castle Technology Ltd.

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

Options

  • Tickets
  • New ticket
  • Milestones
  • Subversion: Changesets
  • Subversion: Browse
  • CVS: Revisions
  • CVS: Browse
  • Search

RSS feeds Rss

  • Tickets
  • Everything!
  • More feeds...
Site design © RISC OS Open Limited 2011 except where indicated
The RISC OS Open Collaboa theme is distantly based on the Collaboa default layout

Valid XHTML 1.0  |  Valid CSS

Powered by Collaboa
This site runs on Rails

Hosted by Arachsys