Skip to content

missing cast in os.cc fails the build on OpenBSD

building 1.2.4 on OpenBSD fails with:

os.cc:330:47: error: non-constant-expression cannot be narrowed from type 'unsigned int' to 'gint' (aka 'int') in initializer list [-Wc++11-narrowing]
        gint mib[] = {CTL_KERN, KERN_CPTIME2, i - 1};
                                              ^~~~~
os.cc:330:47: note: insert an explicit cast to silence this issue
        gint mib[] = {CTL_KERN, KERN_CPTIME2, i - 1};
                                              ^~~~~
                                              static_cast<gint>( )
1 error generated.

i guess that's due to switching to c++ builds ? 1.2.3 built fine.

using the suggestion from llvm fixes the build:

gint mib[] = {CTL_KERN, KERN_CPTIME2, static_cast<gint>(i) - 1};