Skip to content

std::expected link error #132945

Closed as not planned
Closed as not planned
@andrea-cassioli-maersk

Description

@andrea-cassioli-maersk

Compiling the following example

#include <expected>
#include <iostream>

int main() {
  std::expected<int, int> a;
  auto& x = a.value();
  std::cout << x << std::endl;
  return 0;
}

with

/opt/homebrew/opt/llvm@19/bin/clang++ -std=c++23 test-value.cpp

I get the following error

/opt/homebrew/opt/llvm@19/bin/clang++ -std=c++23 test-value.cpp 
Undefined symbols for architecture arm64:
  "std::__1::bad_expected_access<void>::what() const", referenced from:
      vtable for std::__1::bad_expected_access<int> in test-value-22e761.o
  "typeinfo for std::__1::bad_expected_access<void>", referenced from:
      typeinfo for std::__1::bad_expected_access<int> in test-value-22e761.o
  "vtable for std::__1::bad_expected_access<void>", referenced from:
      std::__1::bad_expected_access<void>::bad_expected_access[abi:ne190107]() in test-value-22e761.o
   NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

some more info

➜  tmp /opt/homebrew/opt/llvm@19/bin/clang++ -v
Homebrew clang version 19.1.7
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/19.1.7_1/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin23.cfg
System configuration file directory: /opt/homebrew/etc/clang
User configuration file directory: /Users/xxxxxxx/.config/clang

Compiling with clang version 18 gives no error.

Not sure what is the issue. Hope someone can help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions