https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85296

            Bug ID: 85296
           Summary: [nvptx] pr85244-1.c execution failure
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

We see failures for this testcase:
...
PASS: gcc.dg/torture/pr85244-1.c   -O0  (test for excess errors)
FAIL: gcc.dg/torture/pr85244-1.c   -O0  execution test
PASS: gcc.dg/torture/pr85244-1.c   -O1  (test for excess errors)
FAIL: gcc.dg/torture/pr85244-1.c   -O1  execution test
PASS: gcc.dg/torture/pr85244-1.c   -O2  (test for excess errors)
FAIL: gcc.dg/torture/pr85244-1.c   -O2  execution test
PASS: gcc.dg/torture/pr85244-1.c   -O3 -g  (test for excess errors)
FAIL: gcc.dg/torture/pr85244-1.c   -O3 -g  execution test
PASS: gcc.dg/torture/pr85244-1.c   -Os  (test for excess errors)
FAIL: gcc.dg/torture/pr85244-1.c   -Os  execution test
...

The execution failure is due to a cuda linking error:
...
spawn nvptx-none-run ./pr85244-1.exe
error   : Size doesn't match for 'val' in 'input file 2 at offset 3047', first
specified in 'input file 1 at offset 1805'
nvptx-run: cuLinkAddData failed: unknown error (CUDA_ERROR_UNKNOWN, 999)
...

In pr85244-1.c we have:
...
struct s {
 long a;
 int b;
 int tab[];
};

extern const struct s val;
...

and in pr85244-2.c we have:
...
const struct s val = { 0, 0, { 42, 1337 } };
...

In pr85244-2.s we have (where 42 is 0x2a and 180388626432 is 0x2A00000000):
...
        .visible .const .align 8 .u64 val[3] = { 0, 180388626432, 1337 };       
...

but in pr85244-1.s:
...
        .extern .const .align 8 .u64 val[2];                                    
...

Changing the 'val[2]' to 'val[]' makes the test pass.

Reply via email to