Skip to content

Bundled dxflib: DL_HatchEdgeData triggers -Wuninitialized with -Werror #372

@rampageservices

Description

@rampageservices

Problem

The bundled dxflib code emits -Wuninitialized / -Wmaybe-uninitialized warnings when compiled with -Wall:

dl_entities.h:1539:22: error: '<anonymous>.DL_HatchEdgeData::type' is used uninitialized [-Werror=uninitialized]
 1539 | struct DXFLIB_EXPORT DL_HatchEdgeData {

Triggered at dl_dxf.cpp:606 and dl_dxf.cpp:2018 where hatchEdge = DL_HatchEdgeData() default-constructs the struct. GCC flags the implicit move-assignment of uninitialized members as a potential use-before-init, even though the struct is being reset (not read).

This is a false positive in GCC's analysis — the default constructor value-initializes all members — but it fires reliably with -O3 inlining.

Current workaround

PR #369 suppresses -Wno-uninitialized and -Wno-maybe-uninitialized on the bundled dxflib source files via set_source_files_properties. This keeps -Werror working for gerbv's own code.

Upstream fix

The proper fix is in dxflib itself (QCAD): either adding a user-defined default constructor to DL_HatchEdgeData that explicitly initializes all members, or using = {} member initializers. This should be reported to https://github.com/qcad/qcad.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions