Skip to content

Weak alias to static function not working #18149

@llvmbot

Description

@llvmbot
Bugzilla Link 17775
Version trunk
OS Linux
Blocks #44654
Attachments Minimal reproducer for weak-alias problem
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@slacka,@tstellar

Extended Description

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 problems.

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 static.

-- Scott

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"extension:gnu

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions