Skip to content

Fix implicitly-deleted default constructor error on older Xcode versions#8719

Merged
sbc100 merged 1 commit into
mainfrom
fix-istring-default-constructor
May 18, 2026
Merged

Fix implicitly-deleted default constructor error on older Xcode versions#8719
sbc100 merged 1 commit into
mainfrom
fix-istring-default-constructor

Conversation

@sbc100
Copy link
Copy Markdown
Member

@sbc100 sbc100 commented May 18, 2026

Older versions of Clang (particularly those shipped with older Xcode versions) are more strict about the initialization of const members. According to the C++ standard, if a class has a const member that is not initialized at the point of declaration and lacks a user-provided default constructor that initializes it, the default constructor is implicitly deleted.

While newer versions of Clang and other compilers may allow this if the member has a trivial default constructor (like our View struct, which has an inline initializer for its only member), older versions of Apple Clang have been known to reject this, leading to build failures when inheriting from IString (e.g., in the Name class).

This change provides an explicit default constructor for IString that initializes the 'str' member, ensuring compatibility across a wider range of compiler versions.

@sbc100 sbc100 requested a review from a team as a code owner May 18, 2026 18:23
@sbc100 sbc100 requested review from tlively and removed request for a team May 18, 2026 18:23
@sbc100
Copy link
Copy Markdown
Member Author

sbc100 commented May 18, 2026

@tlively I'm afraid to say Gemini came up with move 90% of this, but it seems reasonable. I don't have any easy way to test on the older Xcode though.

@sbc100 sbc100 force-pushed the fix-istring-default-constructor branch from 85067d1 to d3283c8 Compare May 18, 2026 18:26
Comment thread .github/workflows/ci.yml Outdated
@sbc100 sbc100 force-pushed the fix-istring-default-constructor branch 2 times, most recently from f17e271 to 6d8cc57 Compare May 18, 2026 18:38
Older versions of Clang (particularly those shipped with older Xcode
versions) are more strict about the initialization of const members.
According to the C++ standard, if a class has a const member that is
not initialized at the point of declaration and lacks a user-provided
default constructor that initializes it, the default constructor is
implicitly deleted.

While newer versions of Clang and other compilers may allow this if the
member has a trivial default constructor (like our View struct, which
has an inline initializer for its only member), older versions of Apple
Clang have been known to reject this, leading to build failures when
inheriting from IString (e.g., in the Name class).

This change provides an explicit default constructor for IString that
initializes the 'str' member, ensuring compatibility across a wider
range of compiler versions.
@sbc100 sbc100 force-pushed the fix-istring-default-constructor branch from 6d8cc57 to 38dc263 Compare May 18, 2026 18:49
@sbc100 sbc100 enabled auto-merge (squash) May 18, 2026 19:08
@sbc100 sbc100 changed the title Fix implicitly-deleted default constructor error on older Xcode version. Fix implicitly-deleted default constructor error on older Xcode versions May 18, 2026
@sbc100 sbc100 merged commit 731a473 into main May 18, 2026
16 checks passed
@sbc100 sbc100 deleted the fix-istring-default-constructor branch May 18, 2026 19:40
sbc100 added a commit that referenced this pull request May 18, 2026
In emsdk we actually build on macos-13, but sadly there is not macos-13
available in github actions.

In doing this I'm trying to get binaryen CI to reproduce the current
issue we are seeing in emsdk CI:
```
In file included from /Users/distiller/project/binaryen/main/src/ir/import-names.h:23:
/Users/distiller/project/binaryen/main/src/support/name.h:35:12: error: call to implicitly-deleted default constructor of 'wasm::IString'
  Name() : IString() {}
           ^
/Users/distiller/project/binaryen/main/src/support/istring.h:72:3: note: explicitly defaulted function was implicitly deleted here
  IString() = default;
  ^
/Users/distiller/project/binaryen/main/src/support/istring.h:68:14: note: default constructor of 'IString' is implicitly deleted because field 'str' of const-qualified type 'const wasm::IString::View' would not be initialized
  const View str;
             ^
```

Split out from #8719
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants