This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/52336] New: Change the private field without any warning or error.
- From: "maxim.prohorenko at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 22 Feb 2012 07:16:52 +0000
- Subject: [Bug c/52336] New: Change the private field without any warning or error.
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52336
Bug #: 52336
Summary: Change the private field without any warning or error.
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: maxim.prohorenko@gmail.com
// base
class base
{
public:
base () : mask_private_with_warning (0), private_with_warning (0) {}
private:
// private union
union
{
struct
{
unsigned int private_bit_without_warning : 1;
};
unsigned int mask_private_with_warning;
};
// private field
unsigned int private_with_warning;
};
class der : public base
{
};
int main (int , char **)
{
der d;
d.mask_private_with_warning = 1;
d.private_with_warning = 1;
d.private_bit_without_warning = 1;
#warning "private private_bit_without_warning"
return 0;
}
// gcc 4.6.2 -Wall -W -Wcast-align -Werror -Wfloat-equal -Wpointer-arith
-Wunused -Wwrite-strings -Wno-long-long -std=gnu++98 -Wuninitialized -Wformat=1
-Wformat-security -Wcast-qual
//--cut---------------
/home/prohorenko/projects/gcc_bug_private/build> make
[100%] Building CXX object CMakeFiles/gcc_bug_private.dir/main.cpp.o
/home/prohorenko/projects/gcc_bug_private/main.cpp:34:2: error: #warning
"private private_bit_without_warning"
/home/prohorenko/projects/gcc_bug_private/main.cpp: In function âint main(int,
char**)â:
/home/prohorenko/projects/gcc_bug_private/main.cpp:16: error: âunsigned int
base::<anonymous union>::mask_private_with_warningâ is private
/home/prohorenko/projects/gcc_bug_private/main.cpp:30: error: within this
context
/home/prohorenko/projects/gcc_bug_private/main.cpp:20: error: âunsigned int
base::private_with_warningâ is private
/home/prohorenko/projects/gcc_bug_private/main.cpp:31: error: within this
context
make[2]: *** [CMakeFiles/gcc_bug_private.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/gcc_bug_private.dir/all] Error 2
make: *** [all] Error 2
*** Failed ***