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: unassignedclangb...@nondot.org
          Reporter: john.br...@arm.com
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to