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

[Bug]: Uninitialized value in AnyInvocable. #1693

Open
vitaliy-aksyonov opened this issue Jun 20, 2024 · 0 comments
Open

[Bug]: Uninitialized value in AnyInvocable. #1693

vitaliy-aksyonov opened this issue Jun 20, 2024 · 0 comments

Comments

@vitaliy-aksyonov
Copy link

Describe the issue

Uninitialized value in AnyInvocable.

Steps to reproduce the problem

When move from one instance of AnyInvocable to another, GCC v 12+ with -O2 or more and -Wall complains about uninitialized value used.
Example: https://godbolt.org/z/c4KMhcYcc
If change to -O1 - warning disappear.

In file included from /opt/compiler-explorer/libs/abseil/absl/functional/any_invocable.h:43,
                 from <source>:1:
In function 'void absl::internal_any_invocable::LocalManagerTrivial(FunctionToCall, TypeErasedState*, TypeErasedState*)',
    inlined from 'absl::internal_any_invocable::CoreImpl<SigIsNoexcept, ReturnType, P>::CoreImpl(absl::internal_any_invocable::CoreImpl<SigIsNoexcept, ReturnType, P>&&) [with bool SigIsNoexcept = false; ReturnType = void; P = {}]' at /opt/compiler-explorer/libs/abseil/absl/functional/internal/any_invocable.h:481:11,
    inlined from 'absl::internal_any_invocable::Impl<void()>::Impl(absl::internal_any_invocable::Impl<void()>&&)' at /opt/compiler-explorer/libs/abseil/absl/functional/internal/any_invocable.h:868:1,
    inlined from 'absl::AnyInvocable<Sig>::AnyInvocable(absl::AnyInvocable<Sig>&&) [with Sig = void()]' at /opt/compiler-explorer/libs/abseil/absl/functional/any_invocable.h:184:3,
    inlined from 'int main()' at <source>:7:49:
/opt/compiler-explorer/libs/abseil/absl/functional/internal/any_invocable.h:266:7: warning: 'fn.absl::AnyInvocable<void()>::<unnamed>.absl::internal_any_invocable::Impl<void()>::<unnamed>.absl::internal_any_invocable::CoreImpl<false, void>::state_' is used uninitialized [-Wuninitialized]
  266 |   *to = *from;
      |   ~~~~^~~~~~~
<source>: In function 'int main()':
<source>:6:32: note: 'fn' declared here
    6 |     absl::AnyInvocable<void()> fn{[](){ std::cout << "test\n"; }};
      |                                ^~
ASM generation compiler returned: 0
In file included from /opt/compiler-explorer/libs/abseil/absl/functional/any_invocable.h:43,
                 from <source>:1:
In function 'void absl::internal_any_invocable::LocalManagerTrivial(FunctionToCall, TypeErasedState*, TypeErasedState*)',
    inlined from 'absl::internal_any_invocable::CoreImpl<SigIsNoexcept, ReturnType, P>::CoreImpl(absl::internal_any_invocable::CoreImpl<SigIsNoexcept, ReturnType, P>&&) [with bool SigIsNoexcept = false; ReturnType = void; P = {}]' at /opt/compiler-explorer/libs/abseil/absl/functional/internal/any_invocable.h:481:11,
    inlined from 'absl::internal_any_invocable::Impl<void()>::Impl(absl::internal_any_invocable::Impl<void()>&&)' at /opt/compiler-explorer/libs/abseil/absl/functional/internal/any_invocable.h:868:1,
    inlined from 'absl::AnyInvocable<Sig>::AnyInvocable(absl::AnyInvocable<Sig>&&) [with Sig = void()]' at /opt/compiler-explorer/libs/abseil/absl/functional/any_invocable.h:184:3,
    inlined from 'int main()' at <source>:7:49:
/opt/compiler-explorer/libs/abseil/absl/functional/internal/any_invocable.h:266:7: warning: 'fn.absl::AnyInvocable<void()>::<unnamed>.absl::internal_any_invocable::Impl<void()>::<unnamed>.absl::internal_any_invocable::CoreImpl<false, void>::state_' is used uninitialized [-Wuninitialized]
  266 |   *to = *from;
      |   ~~~~^~~~~~~
<source>: In function 'int main()':
<source>:6:32: note: 'fn' declared here
    6 |     absl::AnyInvocable<void()> fn{[](){ std::cout << "test\n"; }};
      |     

What version of Abseil are you using?

latest from git

What operating system and version are you using?

linux

What compiler and version are you using?

gcc v 12.1

What build system are you using?

none

Additional context

No response

@vitaliy-aksyonov vitaliy-aksyonov changed the title [Bug]: Please title this bug report [Bug]: Uninitialized value in AnyInvocable. Jun 20, 2024
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

No branches or pull requests

1 participant