Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link error caused by conforming C++ type to Equatable #72826

Closed
wtholliday opened this issue Apr 4, 2024 · 2 comments
Closed

link error caused by conforming C++ type to Equatable #72826

wtholliday opened this issue Apr 4, 2024 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ c++ to swift Feature → c++ interop: c++ to swift compiler The Swift compiler itself conformances Feature → protocol: protocol conformances Equatable Area → standard library: The `Equatable` protocol linker error multiple files Flag: An issue whose reproduction requires multiple files swift 5.10 unexpected error Bug: Unexpected error

Comments

@wtholliday
Copy link

wtholliday commented Apr 4, 2024

Description

After conforming a C++ type to Equatable, I get a link error. This requires using attached project since it seems the extension needs to be in a separate translation unit.

CompilerCrash.zip

duplicate symbol '_$sSo11SharedThingVMa' in:
    [redacted]/Build/Products/Debug/TestTarget2.o
    [redacted]/Build/Intermediates.noindex/CompilerCrash.build/Debug/CompilerCrash.build/Objects-normal/arm64/CompilerCrashApp.o

Reproduction

let thing = SharedThing.create()
let array = [thing, thing]
extension SharedThing: Equatable {
    public static func == (lhs: SharedThing, rhs: SharedThing) -> Bool {
        true
    }
}

where SharedThing is:

#pragma once

#include "IntrusiveRefCounted.hpp"
#include <swift/bridging>

struct SharedThing : public IntrusiveRefCounted<SharedThing> {

    static SharedThing* _Nonnull create();

    ~SharedThing();

private:
} SWIFT_SHARED_REFERENCE(retainSharedThing, releaseSharedThing);

void retainSharedThing(SharedThing * _Nonnull);
void releaseSharedThing(SharedThing * _Nonnull);

Expected behavior

No link error

Environment

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

Additional information

No response

@wtholliday wtholliday added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Apr 4, 2024
@AnthonyLatsis AnthonyLatsis added c++ interop Feature: Interoperability with C++ conformances Feature → protocol: protocol conformances multiple files Flag: An issue whose reproduction requires multiple files linker error Equatable Area → standard library: The `Equatable` protocol unexpected error Bug: Unexpected error c++ to swift Feature → c++ interop: c++ to swift swift 5.10 compiler The Swift compiler itself and removed triage needed This issue needs more specific labels labels Apr 4, 2024
@MaxDesiatov
Copy link
Contributor

cc @egorzhdan

@egorzhdan egorzhdan self-assigned this Apr 4, 2024
@egorzhdan
Copy link
Contributor

This was fixed by #74208.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ c++ to swift Feature → c++ interop: c++ to swift compiler The Swift compiler itself conformances Feature → protocol: protocol conformances Equatable Area → standard library: The `Equatable` protocol linker error multiple files Flag: An issue whose reproduction requires multiple files swift 5.10 unexpected error Bug: Unexpected error
Projects
None yet
Development

No branches or pull requests

4 participants