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

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

Reply via email to