[llvm-bugs] [Bug 42813] New: Clang should give an error for .bss variables with invalid initializer

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 29 08:16:14 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42813

            Bug ID: 42813
           Summary: Clang should give an error for .bss variables with
                    invalid initializer
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: john.brawn at arm.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Currently if you compile a file containing this

  int x __attribute__((section(".bss"))) = 1;

You get a fatal error in the backend

  fatal error: error in backend: non-zero initializer found in section '.bss'

Or if the initializer is an address

  int x = 1;
  int *p __attribute__((section(".bss"))) = &x;

you get a slightly different error

  fatal error: error in backend: cannot have fixups in virtual section!


We should be giving a proper error in the frontend, rather than failing with a
fatal error in the backend. gcc already does this, and gives the error

  tmp.c:2:6: error: only zero initializers are allowed in section '.bss'
      2 | int *p __attribute__((section(".bss"))) = &x;
        |      ^

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190729/4a600e4a/attachment.html>


More information about the llvm-bugs mailing list