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

warning fix #571

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

warning fix #571

wants to merge 1 commit into from

Conversation

Jbudone
Copy link

@Jbudone Jbudone commented Dec 3, 2022

Fix non-trivial copy assignment warning in memset usage

make: Entering directory '/home/jbud/repositories/node-pty/build'
  CXX(target) Release/obj.target/pty/src/unix/pty.o
../src/unix/pty.cc: In function ‘void pty_after_waitpid(uv_async_t*)’:
../src/unix/pty.cc:534:9: warning: ‘void* memset(void*, int, size_t)’ writing to an object of type ‘class Nan::Persistent<v8::Function>’ with no trivial copy-assignment [-Wclass-memaccess]
  534 |   memset(&baton->cb, -1, sizeof(baton->cb));
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@Tyriar
Copy link
Member

Tyriar commented Dec 5, 2022

@deepak1556 is this just suppressing the warning? I see https://stackoverflow.com/a/66596764/1156119 recommends against it

@Tyriar Tyriar added this to the 1.0.0 milestone Dec 5, 2022
@deepak1556
Copy link
Contributor

I would recommend using v8::NonCopyablePersistentTraits instead.

@Jbudone
Copy link
Author

Jbudone commented Dec 6, 2022

I don't quite understand 🙈 How can I use v8::NonCopyablePersistentTraits here?

I tried changing the type here:

struct pty_baton {
  Nan::Persistent<v8::Function, v8::NonCopyablePersistentTraits<v8::Function>> cb;

But the warning persists:

make: Entering directory '/home/jbud/repositories/node-pty/build'
  CXX(target) Release/obj.target/pty/src/unix/pty.o
../src/unix/pty.cc: In function ‘void pty_after_waitpid(uv_async_t*)’:
../src/unix/pty.cc:534:9: warning: ‘void* memset(void*, int, size_t)’ writing to an object of type ‘class Nan::Persistent<v8::Function>’ with no trivial copy-assignment [-Wclass-memaccess]
  534 |   memset(&baton->cb, -1, sizeof(baton->cb));
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@Tyriar Tyriar marked this pull request as draft December 6, 2022 17:26
@Tyriar Tyriar removed this from the 1.0.0 milestone Jun 9, 2023
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.

None yet

3 participants