Bug 471995 - cursorkindtraits.h fails to build with Clang 16 and C++17
Summary: cursorkindtraits.h fails to build with Clang 16 and C++17
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Code completion (show other bugs)
Version: unspecified
Platform: Other All
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
: 475458 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-07-06 08:47 UTC by Raphael Kubo da Costa
Modified: 2023-10-11 08:05 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.12.230800


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raphael Kubo da Costa 2023-07-06 08:47:05 UTC
See e.g. https://pkg-status.freebsd.org/beefy18/data/main-amd64-default/p7520ea4fbadd_sfd774e065c/logs/kdevelop-23.04.1_1.log

In file included from /wrkdirs/usr/ports/devel/kdevelop/work/kdevelop-23.04.1/plugins/clang/codecompletion/completionhelper.cpp:9:
/wrkdirs/usr/ports/devel/kdevelop/work/kdevelop-23.04.1/plugins/clang/codecompletion/../duchain/cursorkindtraits.h:217:7: error: integer value -1 is outside the valid range of values [0, 255] for the enumeration type 'CommonIntegralTypes' [-Wenum-constexpr-conversion]
    : static_cast<IntegralType::CommonIntegralTypes>(-1);
      ^
Comment 1 Bug Janitor Service 2023-07-07 11:02:12 UTC
A possibly relevant merge request was started @ https://invent.kde.org/kdevelop/kdevelop/-/merge_requests/462
Comment 2 Igor Kushnir 2023-07-07 11:42:27 UTC
I haven't tested whether Clang 16 builds KDevelop successfully with my fix. Would appreciate if someone else tested the linked merge request.
Comment 3 Raphael Kubo da Costa 2023-07-07 16:32:37 UTC
I can confirm that the patch in the MR fixes the build wit clang 16. Thanks for the quick fix!
Comment 4 Igor Kushnir 2023-07-08 09:52:59 UTC
Git commit ede1cf4ad6f945349060db9446c489e3fd34dec4 by Igor Kushnir.
Committed on 07/07/2023 at 10:58.
Pushed by igorkushnir into branch 'master'.

Don't cast out-of-enum-range -1 to CommonIntegralTypes

This fixes the following Clang 16 compilation error:
kdevelop/plugins/clang/duchain/cursorkindtraits.h:217:7: error: integer value -1 is outside the valid range of values [0, 255] for the enumeration type 'CommonIntegralTypes' [-Wenum-constexpr-conversion]
    : static_cast<IntegralType::CommonIntegralTypes>(-1);

Quote from https://github.com/llvm/llvm-project/issues/59036 :
    The -Wenum-constexpr-conversion warning was created to account for
    the fact that casting integers to enums outside of the valid range
    of the enum is UB in C++17. Constant expressions invoking UB lead to
    an ill-formed program.
FIXED-IN: 5.12.230800

M  +2    -1    kdevplatform/language/duchain/types/integraltype.h
M  +1    -1    plugins/clang/duchain/builder.cpp
M  +1    -1    plugins/clang/duchain/cursorkindtraits.h

https://invent.kde.org/kdevelop/kdevelop/-/commit/ede1cf4ad6f945349060db9446c489e3fd34dec4
Comment 5 Igor Kushnir 2023-10-11 08:05:00 UTC
*** Bug 475458 has been marked as a duplicate of this bug. ***