[Bug c/77992] Provide feature to initialize padding bytes to avoid information leaks

2019-12-15 Thread mine260309 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77992

Lei YU  changed:

   What|Removed |Added

 CC||mine260309 at gmail dot com

--- Comment #18 from Lei YU  ---
I hit the exact same problem with GCC 7.4.0 and 9.2.1, and finds out that:
* When all fields are initialized, the padding bytes are not initialized;
* When there is a field is not provided with init value, the padding bytes are
initialized to 0.

See below code snippet:

#include 
#include 
#include 

struct struct_with_padding {
uint32_t a;
uint64_t b;
uint32_t c;
};
int main()
{
struct struct_with_padding s;
memset(&s, 0xff, sizeof(s));
s = (struct struct_with_padding) {
.a = 0x,
.b = 0x,
#ifdef SHOW_GCC_BUG
.c = 0x,
#else
//.c = 0x,
#endif
};

uint8_t* p8 = (uint8_t*)(&s);

printf("data: ");
for (size_t i = 0; i < sizeof(s); ++i)
{
printf("0x%02x ", p8[i]);
}
printf("\n");
return 0;
}


With `.c = 0x`, the example output:

data: 0xaa 0xaa 0xaa 0xaa 0xff 0xff 0xff 0xff 0xbb 0xbb 0xbb 0xbb 0xbb 0xbb
0xbb 0xbb 0xdd 0xdd 0xdd 0xdd 0xff 0xff 0xff 0xff

Without that, the example output:

data: 0xaa 0xaa 0xaa 0xaa 0x00 0x00 0x00 0x00 0xbb 0xbb 0xbb 0xbb 0xbb 0xbb
0xbb 0xbb 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00


So it looks like GCC could be improved by initializing the padding bytes in
both cases?

[Bug libstdc++/90415] [9/10 Regression] std::is_copy_constructible> is incomplete

2019-08-07 Thread mine260309 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90415

Lei YU  changed:

   What|Removed |Added

 CC||mine260309 at gmail dot com

--- Comment #6 from Lei YU  ---
This issue prevents using std::any with gmock, which I need it for the unit
tests to pass the build.

There are related SO questions:
*
https://stackoverflow.com/questions/57332965/incomplete-type-for-stdany-when-gmocking-interface
*
https://stackoverflow.com/questions/57387245/using-stdany-with-gmock-result-in-different-behavior-on-gcc-79

@Jonathan Wakely Is there a quick fix for this? I would like to test it.

[Bug libstdc++/90415] [9/10 Regression] std::is_copy_constructible> is incomplete

2019-08-08 Thread mine260309 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90415

--- Comment #7 from Lei YU  ---
Additional information.

std::experimental::fundamentals_v1::any has no problem, so the below code
compiles fine.

```
#include 
#include 
#include 

bool is_copy_constructible_tuple_any() {
return
std::is_copy_constructible>::value;
}
```