# False-negative for S2183 in enum values

**URL:** <https://community.sonarsource.com/t/false-negative-for-s2183-in-enum-values/134858>\
**Category:** Visual Studio\
**Tags:** visualstudio, csharp, false-negative\
**Created:** [February 10, 2025, 5:27am UTC](https://community.sonarsource.com/t/false-negative-for-s2183-in-enum-values/134858 "2025-02-10T05:27:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trisibo](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/trisibo/32/63994_2.png) [@Trisibo](https://community.sonarsource.com/u/Trisibo)\
**Post date:** [February 10, 2025, 5:27am UTC](https://community.sonarsource.com/t/false-negative-for-s2183-in-enum-values/134858/1 "2025-02-10T05:27:17Z")

</div>

- Language: C#
- Rule: S2183
- Product: SonarQube for Visual Studio 8.11.0.11944
- IDE: Visual Studio Community 2022 17.12.4
- Connected mode: No

The rule S2183 (“Integral numbers should not be shifted by zero or more than their number of bits-1”) doesn’t trigger for the values in `enum` types when shifting by the number of bits or more. For example:

```auto
internal static class Program
{
    static void Main()
    {
        int meow = 1 << 63; // Generates S2183.
    }

    enum MyEnum
    {
        Meow = 1 << 63 // Does not generate S2183.
    }
}

```

To me it seems OK that it doesn’t trigger when shifting by 0 in enums, but not by the number of bits or more, as that’s most probably a bug.

---

<div class="post-metadata">

**Author:** ![sebastien.marichal](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/sebastien.marichal/32/69045_2.png) [@sebastien.marichal](https://community.sonarsource.com/u/sebastien.marichal)\
**Post date:** [February 10, 2025, 2:13pm UTC](https://community.sonarsource.com/t/false-negative-for-s2183-in-enum-values/134858/4 "2025-02-10T14:13:56Z")

</div>

Hello @Trisibo,

Thank you for raising this with us!

It is indeed a false negative, I have opened a ticket in our backlog so we can tackle it in the future.

Have a nice day,

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [February 19, 2025, 1:56pm UTC](https://community.sonarsource.com/t/false-negative-for-s2183-in-enum-values/134858/9 "2025-02-19T13:56:46Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
