Skip to content

Compilation Warning clearing non-trivial object. #2

@dfloer

Description

@dfloer

When compiling, we get a warning of:

FreqEstimator.cpp: In constructor ‘FreqEstimator::FreqEstimator(int)’:
FreqEstimator.cpp:44:66: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct std::complex<float>’; use assignment or value-initialization instead [-Wclass-memaccess]
   44 |     memset(m_input, 0, sizeof(std::complex < float > ) * m_frames);
      |                                                                  ^
In file included from FreqEstimator.h:19,
                 from FreqEstimator.cpp:19:
/usr/include/c++/9.2.0/complex:1076:12: note: ‘struct std::complex<float>’ declared here
 1076 |     struct complex<float>
      |            ^~~~~~~~~~~~~~

This could lead to unexpected behaviour, and causes compilation issues. The warning can be suppressed with -Wno-class-memaccess.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbuildIssues relating the the build of the project.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions