LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 39401 - Detect int to enum narrowing conversion
Summary: Detect int to enum narrowing conversion
Status: NEW
Alias: None
Product: clang-tools-extra
Classification: Unclassified
Component: clang-tidy (show other bugs)
Version: unspecified
Hardware: All All
: P enhancement
Assignee: Guillaume Chatelet
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-23 04:40 PDT by Guillaume Chatelet
Modified: 2018-11-30 13:50 PST (History)
6 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume Chatelet 2018-10-23 04:40:08 PDT
#include <cstdint>

enum Enum : uint8_t {};

Enum foo(int NewValue) {
    return Enum(NewValue);
}

The construction of an enum with a wider type should add a narrowing conversion warning.