Skip to content

Clang crashes when compiling Objective C++ BLOCK capturing and using outer ivar in a class member initializer #94027

@kar8uncle

Description

@kar8uncle

Clang crashes when compiling the following program: clang++ -fobjc-arc -std=c++11 -o main.o main.mm

#import <Foundation/Foundation.h>

@interface Foo : NSObject
@end

@implementation Foo
{
    id _bar;
}

- (void)captureBar
{
    (void) ^{
        struct
        {
            id bar = _bar;
        } fb;
    };
}
@end

Version

This clang came with Xcode 15.2.

Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.5.0
Thread model: posix

Metadata

Metadata

Assignees

No one assigned

    Labels

    clangClang issues not falling into any other categorycrashPrefer [crash-on-valid] or [crash-on-invalid]objective-c++

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions