-
-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Using CHECK with bitfield fails to compile #786 Use rvalue reference instead of universal reference so that bitfields bind to const lvalue * Using CHECK with bitfield fails to compile #786 Removing changes not related to win32 * Pragma pack for windows
- Loading branch information
1 parent
66ff54a
commit d7a5eeb
Showing
7 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <doctest/doctest.h> | ||
|
||
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN | ||
#include <cstdint> | ||
#include <sstream> | ||
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END | ||
|
||
DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") | ||
DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") | ||
|
||
#ifndef WIN32 | ||
struct __attribute__((packed)) P { | ||
int i; | ||
}; | ||
TEST_CASE("packed_struct") { | ||
P p; | ||
p.i = 0; | ||
CHECK(p.i == 0); // error: cannot bind packed field ‘s.S::i’ to ‘int&’ | ||
//CHECK(int(s.i) == 0); // 'useless cast' | ||
} | ||
#else | ||
#pragma pack(push, 1) | ||
struct P { | ||
int i; | ||
}; | ||
TEST_CASE("packed_struct") { | ||
P p; | ||
p.i = 0; | ||
CHECK(p.i == 0); // error: cannot bind packed field ‘s.S::i’ to ‘int&’ | ||
//CHECK(int(s.i) == 0); // 'useless cast' | ||
} | ||
#pragma pack(pop) | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <doctest/doctest.h> | ||
|
||
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN | ||
#include <cstdint> | ||
#include <sstream> | ||
DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END | ||
|
||
DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") | ||
DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") | ||
|
||
struct S { | ||
uint32_t a : 31; | ||
uint32_t b : 1; | ||
}; | ||
TEST_CASE("bitfield") { | ||
S s; | ||
s.a = 0; | ||
s.b = 1; | ||
CHECK(s.a == 0); // error here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[doctest] run with "--help" for options | ||
=============================================================================== | ||
[doctest] test cases: 0 | 0 passed | 0 failed | 106 skipped | ||
[doctest] test cases: 0 | 0 passed | 0 failed | 108 skipped | ||
[doctest] assertions: 0 | 0 passed | 0 failed | | ||
[doctest] Status: SUCCESS! | ||
Program code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters