[LLVMbugs] [Bug 17775] New: Weak alias to static function not working

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Nov 1 14:11:05 PDT 2013


            Bug ID: 17775
           Summary: Weak alias to static function not working
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: scott+llvm+bugzilla at pakin.org
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 11473
  --> http://llvm.org/bugs/attachment.cgi?id=11473&action=edit
Minimal reproducer for weak-alias problem

Weak aliases to unused static functions fail with an error message.  It looks
like the compiler is first removing the unused static function then complaining
that it can't create a weak alias to a function that no longer exists:

$ clang++ --version | head -1
clang version 3.4 (trunk)
$ clang++ -c aliasing.cpp 
aliasing.cpp:8:56: error: alias must point to a defined variable or function
  const char* do_something (void) __attribute__((weak, alias("do_somethi...
1 error generated.
$ g++ --version | head -1
g++ (GCC) 4.7.2
$ g++ -c aliasing.cpp 

I'm seeing this problem with r193799, but I recall it working in r190315.  This
seems to be a C++ issue; analogous C code made it through clang with no

Defining do_something_original() as non-static in the attached file makes the
problem go away, but in my real code I'd prefer to have the function declared

-- Scott

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/20131101/eb0df25e/attachment.html>

More information about the llvm-bugs mailing list