Skip to content

Clang should never emit zero-length functions if they may be address-taken #32380

@pcc

Description

@pcc
Bugzilla Link 33033
Version unspecified
OS Linux
CC @zmodem,@zygoloid

Extended Description

If the linker places a zero-length function at the same address as another function, function pointer equality may be broken.

$ cat addr-taken.c

#include <stdio.h>
void f1() { __builtin_unreachable(); }
void f2() { __builtin_unreachable(); }
int main() {
  printf("%p %p\n", &f1, &f2);
}

$ clang -Os addr-taken.c
$ ./a.out
0x400510 0x400510

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:codegenIR generation bugs: mangling, exceptions, etc.confirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions