catchorg / catchorg/Catch2

Enum comparison unexpectedly passes

Open
#827 5 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

## Description

I've got a scenario where comparing an unsigned int against any enum value unexpectedly passes.

### Steps to reproduce

MWE:

```
#include "catch.hpp"

enum
{
option_1 = 1,
option_2 = 2,
};

TEST_CASE( "what happened to my enum comparison?" )
{
const unsigned opt = option_1;

if( opt == option_2 )
{
REQUIRE(false); // never reached, good
}

CHECK( opt == option_2 ); // unexpected pass?!
CHECK( ( opt == option_2 ) ); // expected fail
}
```

### Extra information

* Catch version: **v1.7.2**
* Operating System: **SUSE Linux Enterprise Server 11 SP3 (i586)**
* Compiler+version: **gcc (SUSE Linux) 4.3.4 [gcc-4_3-branch revision 152973]**

However, this does work on Ubuntu 16.04, with gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 (Catch 1.7.2)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.