Skip to content

[SR-15229] static_assert failure when using cxx interop + Foundation + libstcd++ 10 on Ubuntu #3202

Open
@swift-ci

Description

@swift-ci
Previous ID SR-15229
Radar rdar://problem/83411414
Original Reporter natinusala (JIRA User)
Type Bug
Environment
  • Ubuntu 20.04

  • Swift 5.5 (september 20th-something release) official build

  • stdlib installed with libstdc++-10-dev

Additional Detail from JIRA
Votes 0
Component/s Compiler, Foundation
Labels Bug
Assignee None
Priority Medium

md5: 4e189258882818903efee073a7ab5c2c

Issue Description:

When building any file that has :

  • a integer comparison

  • Foundation imported

With `-Xswiftc -enable-experimental-cxx-interop` on an Ubuntu system that has libstdc++ 10, the following error appears :

/usr/include/c++/10/ext/numeric_traits.h:64:7: error: static_assert failed due to requirement '__is_integer_nonstrict<float>::__value' "invalid specialization"
      static_assert(__is_integer_nonstrict<_Value>::__value,
      ^
/usr/include/c++/10/ext/numeric_traits.h:61:12: note: in instantiation of template class '__gnu_cxx::__numeric_traits_integer<float>' requested here
    struct __numeric_traits_integer
           ^
/usr/include/c++/10/ext/numeric_traits.h:64:7: error: static_assert failed due to requirement '__is_integer_nonstrict<double>::__value' "invalid specialization"
      static_assert(__is_integer_nonstrict<_Value>::__value,
      ^
/usr/include/c++/10/ext/numeric_traits.h:61:12: note: in instantiation of template class '__gnu_cxx::__numeric_traits_integer<double>' requested here
    struct __numeric_traits_integer
           ^
/usr/include/c++/10/ext/numeric_traits.h:64:7: error: static_assert failed due to requirement '__is_integer_nonstrict<long double>::__value' "invalid specialization"
      static_assert(__is_integer_nonstrict<_Value>::__value,
      ^
/usr/include/c++/10/ext/numeric_traits.h:61:12: note: in instantiation of template class '__gnu_cxx::__numeric_traits_integer<long double>' requested here
    struct __numeric_traits_integer
           ^

If you remove either the Foundation import or the integer comparison, the error goes away. It also goes away if you try to build without the experimental CXX interop feature. Removing libstdc++ 10 is a workaround to the issue, since Swift now seems to use libstc++ 9 instead. or so I thought

Example program (in main.swift of a freshly made executable package) :

import Foundation
print("Hello, world!")
let foobar = 50
if foobar == 50 { print("50") }

Build with :

swift build -Xswiftc -enable-experimental-cxx-interop -c release -v

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions