Skip to content

Error "body of ‘constexpr’ function is not return statement" on build #410

@GiovaGa

Description

@GiovaGa

Building with gcc 11.4. 0 on current develop the following error arises:

[...]
ALP/include/graphblas/base/distribution.hpp:140:33: error: body of ‘constexpr’ function ‘static constexpr size_t grb::internal::Distribution<backend>::local_offset(size_t, size_t, size_t) [with grb::Backend backend = grb::reference; size_t = long unsigned int]’ not a return-statement

Indeed the C++-11 standard dictates that the body of a constexpr function must contain only a return statement (see here ).

The function that triggers the error is the following:

https://github.com/Algebraic-Programming/ALP/blob/2bd1a9ee8b53853199255b26283179d30578f2f3/include/graphblas/base/distribution.hpp#L132C1-L140C6

I see two possible solutions:

  1. Removing the (void) ... statements, but this results in warnings about unused parameters, which is the reason I introduced those lines in the first place.
    Of course we could suppress such warnings, but that's definitely something I would avoid if possible.
  2. Somehow telling the compiler to use a newer C++ standard when compiling this file, as newer versions allow such constexpr functions
    Furthermore the fact that testing passed on the CI and previous testing means that we are likely not explicitly telling the compiler to use a fixed C++ standard version.

I think we should consider this to avoid this kind of unexpected compile errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions