[Bug target/85056] New: [nvptx] wrong declaration of external arrays

cesar at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 23 17:52:00 GMT 2018


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

            Bug ID: 85056
           Summary: [nvptx] wrong declaration of external arrays
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cesar at gcc dot gnu.org
  Target Milestone: ---

Created attachment 43743
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43743&action=edit
test case

The attached test case consists of two files, one containing a definition of an
array 'a', and another using it. To build the program, just run `nvptx-run -O2
main.c extern.c`. nvptx-run reports the following error:

error   : Size doesn't match for 'a' in 'input file 2 at offset 2882', first
specified in 'input file 1 at offset 2171'

There's something wrong with the way that 'a' is being declared for for main.
GCC emitting the declaration as

// BEGIN GLOBAL VAR DECL: a                                                     
.extern .global .align 4 .u32 a; 

But that is really declaring variable 'a' as an integer of size four bytes.
Variable 'a' should be declared as:

// BEGIN GLOBAL VAR DECL: a                                                     
.extern .global .align 4 .u32 a[]; 

Note the additional [] after a.

I was able to reproduce this problem using CUDA 9 / Nvidia driver 390.42 on an
sm_60 GPU using trunk and openacc-gcc-7-branch.


More information about the Gcc-bugs mailing list