[LLVMbugs] [Bug 20066] New: Check undefined init_priority static object dependency

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jun 17 07:15:45 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20066

            Bug ID: 20066
           Summary: Check undefined init_priority static object dependency
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: ich at az2000.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Example:

header.h:

extern int a;
extern int b;

a.cpp:

#include "header.h"
int a = 2;

b.cpp:

#include "header.h"
int b = a;

main.cpp:

#include <stdio.h>
#include "header.h"

__attribute__((constructor))
static void init() {
    printf("init: %i %i\n", a, b);
}

int main() {}

---

a and b will both get the same init_priority (I think it's
DEFAULT_INIT_PRIORITY = 65535), and thus it's not well defined whether a or b
is initialized first.

I would like to have a check, if the initialization of a global/static variable
depends on another global/static variable (int b = a), its init_priority must
be a  bigger value than of all its dependencies.

---

In case that you wont implement this feature in the (near) future, maybe you
can give some guidance about what I need to do to implement such a static check
myself.

-- 
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/20140617/830029ab/attachment.html>


More information about the llvm-bugs mailing list