Skip to content

Compilation warning: initialization discards 'const' qualifier from pointer target type #512

@quarthex

Description

@quarthex

Good day,

On array types, Criterion expect the terms to be mutable.
The framework should handle the case of constant arrays.

Criterion version: 2.4.2
GCC: 13.2.0

#include <criterion/criterion.h>
#include <criterion/new/assert.h>

Test(test, test) {
    const int a[] = {0};
    const int b[] = {0};
    cr_expect(eq(int[1], a, b));
}
test.c: In function 'test_test_impl':
test.c:7:30: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
    7 |     cr_expect(eq(int[1], a, b));
      |                          ^
test.c:7:33: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
    7 |     cr_expect(eq(int[1], a, b));
      |                             ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions