Skip to content

[libc++][NFC] Fix unparenthesized comma expression in mem-initializer #89605

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

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

sdkrystian
Copy link
Member

#84050 resolves class member access expressions naming members of the current instantiation prior to instantiation. In testing, it has revealed a mem-initializer in the move constructor of invocable_with_telemetry that uses an unparenthesized comma expression to initialize a non-static data member of pointer type. This patch fixes it.

@sdkrystian sdkrystian requested a review from a team as a code owner April 22, 2024 13:36
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Apr 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 22, 2024

@llvm/pr-subscribers-libcxx

Author: Krystian Stasiowski (sdkrystian)

Changes

#84050 resolves class member access expressions naming members of the current instantiation prior to instantiation. In testing, it has revealed a mem-initializer in the move constructor of invocable_with_telemetry that uses an unparenthesized comma expression to initialize a non-static data member of pointer type. This patch fixes it.


Full diff: https://github.com/llvm/llvm-project/pull/89605.diff

1 Files Affected:

  • (modified) libcxx/test/support/invocable_with_telemetry.h (+1-1)
diff --git a/libcxx/test/support/invocable_with_telemetry.h b/libcxx/test/support/invocable_with_telemetry.h
index 612bbec639d466..e010837a1624cd 100644
--- a/libcxx/test/support/invocable_with_telemetry.h
+++ b/libcxx/test/support/invocable_with_telemetry.h
@@ -31,7 +31,7 @@ class invocable_with_telemetry {
   constexpr invocable_with_telemetry(invocable_with_telemetry&& other)
     requires std::move_constructible<F>
       : f_(std::move(other.f_)),
-        telemetry_(assert(other.telemetry_ != nullptr), std::exchange(other.telemetry_, nullptr)) {
+        telemetry_((assert(other.telemetry_ != nullptr), std::exchange(other.telemetry_, nullptr))) {
     ++telemetry_->moves;
   }
 

@sdkrystian sdkrystian merged commit 9803196 into llvm:main Apr 22, 2024
@ldionne
Copy link
Member

ldionne commented Apr 22, 2024

For information, we normally wait for the CI to be green before merging. In this case I feel like it's a really trivial change so it's not risky to merge this as-is, but our normal process is to wait for the CI to be green.

@sdkrystian
Copy link
Member Author

@ldionne Alright, I'll keep that in mind for the future. The reason I merged without waiting is because there aren't any tests that instantiate the definition of the move constructor of invocable_with_telemetry.

@philnik777
Copy link
Contributor

I'm very confused. The title says it's NFC, but the description sounds like it fixes a bug. What is it?

@sdkrystian
Copy link
Member Author

@philnik777 I annotated the commit as NFC because it doesn't change the meaning/output of any tests (since no tests rely on it). Prior to this patch, any test that would have caused the definition of the move constructor to be instantiated would fail to compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants