Issue 56468
Summary const volatile variables are placed in the wrong section
Labels new issue
Assignees
Reporter jemarch
    Hello.

clang version 15.0.0 (https://github.com/llvm/llvm-project.git d3dd6e57fe84e90cadcdc78fa71d632f6573f156) places  `const volatile' variables like:

  const volatile int foo = 0;

in the .rodata section.  According to the C18 specification[1]:

  6.7.3 Type qualifiers / 5 The properties associated with qualified
  types are meaningful only for expressions that are lval-values [note
  135]

  135)The implementation may place a const object **that is not
  volatile** in a read-only region of storage. Moreover, the
  implementation need not allocate storage for such an object if its 
  address is never used.

Accordingly, GCC places such variables in the .data section.

Note that this is causing practical difficulties: the kernel's bpftool is generating different skeleton headers for BPF code compiled from LLVM and GCC, because the names of the containing sections get reflected.  For details on this please see [2].

Thanks!

[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf
[2] https://lore.kernel.org/bpf/[email protected]/T/#me726127e166f97fd50f09b647a604f176f809c63
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to