JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
A scoped enumeration (enum class) or unscoped enumeration (enum) contains an enumerator whose value cannot be represented in the underlying type.
Exception case: an unscoped enumeration with implicit underlying type that contains an enumerator whose value cannot be represented will trigger an enum Value Out of Integer Range warning instead.
See also:
This warning class is derived from a C/C++ parser warning.
| Class Name | enum Value Out of Underlying Range | |||
|---|---|---|---|---|
| Significance | reliability | |||
| Mnemonic | PARSE.EVOOUR | |||
| Categories |
|
|||
| Availability | Available for C and C++. |
|||
| Enabling | Checks for this warning class are enabled by default.
However, warning instances of this class that are issued as parser
errors (rather than parser warnings)
will be discarded
when using factory configuration settings.
To prevent these instances from being discarded, add the
following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="enum Value Out of Underlying Range" WARNING_FILTER += discard class="enum Value Out of Underlying Range" |
#include <climits>
enum class ColorScopedBADa: unsigned char {
red = 2000, // 'enum Value Out of Underlying Range' warning issued here
orange
};
enum class ColorScopedBADb { // underlying type is int if not explicitly specified
// ('Enumeration Has Implicit Underlying Type' warning issued here when enabled)
yellow=INT_MAX,
green // 'enum Value Out of Underlying Range' warning issued here
// - green == INT_MAX + 1
};
enum ColorUnscopedOK : unsigned char { // ('Unscoped Enumeration' warning issued here when enabled)
blue,
indigo
};
enum ColorUnscopedBADa : unsigned char { // ('Unscoped Enumeration' warning issued here when enabled)
violet=2000,
black // 'enum Value Out of Underlying Range' warning issued here
// - black == INT_MAX + 1
};
enum ColorUnscopedBADb : unsigned long long { // ('Unscoped Enumeration' warning issued here when enabled)
white=ULLONG_MAX,
cyan // 'enum Value Out of Underlying Range' warning issued here
// - cyan == ULLONG_MAX + 1
};
// Special case: 'enum Value Out of Underlying Range' warnings are not
// triggered in an unscoped enumeration with implicit underlying type.
enum ColorUnscopedBADc { // ('Enumeration Has Implicit Underlying Type' warning issued here when enabled)
// ('Unscoped Enumeration' warning issued here when enabled)
magenta=ULLONG_MAX,
grey // ('enum Value Out of Integer Range' warning issued here when enabled)
};
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.