Skip to content

clang emits C++ guarded initialization for Objective-C static variables in functions #93

Closed
@hyp

Description

@hyp

After commit 2b4fa53, clang has started emitting unexpected __cxa_guard_acquire and __cxa_guard_release checks for static variables in functions in Objective-C code. This breaks a lot of downstream Objective-C code that doesn't have any C++ and doesn't link with libc++/libc++abi.

Patch to partially revert 2b4fa53:
https://reviews.llvm.org/D72411
Test case:

// RUN: %clang_cc1 -triple x86_64-apple-macos10.15 -emit-llvm -fobjc-arc -o - %s | FileCheck %s

@interface I
@end

I *i() {
  static I *i = ((void *)0);
  return i;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions