public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16618] New: In C++, offsetof fails with constant member
@ 2004-07-18 17:36 jrh5y6virbl36ay at optonline dot net
2004-07-19 14:15 ` [Bug c++/16618] [3.4/3.5 regression] " bangerth at dealii dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jrh5y6virbl36ay at optonline dot net @ 2004-07-18 17:36 UTC (permalink / raw)
To: gcc-bugs
gcc-3.4.1, Linux kernel 2.4.26, glibc-2.3.2. Configured with:
../gcc-3.4.1/configure --prefix=/opt/gcc-3.4.1 --enable-threads
--with-system-zlib --enable-__cxa_atexit --with-cpu=pentium4
--with-arch=pentium4 --with-tune=pentium4
This code:
#include <cstddef>
struct test
{
const char a;
};
int main(int argc, char *argv[])
{
size_t n=offsetof(test,a);
}
Leads to:
$ c++ -c 040718a.cc
040718a.cc: In function `int main(int, char**)':
040718a.cc:10: error: reinterpret_cast from type `const char*' to type `char*'
casts away constness
The preprocessor output:
# 1 "040718a.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "040718a.cc"
# 1
"/opt/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/cstddef"
1 3
# 46
"/opt/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/cstddef"
3
# 47
"/opt/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/cstddef"
3
# 1 "/opt/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/include/stddef.h" 1 3 4
# 151 "/opt/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/include/stddef.h" 3 4
typedef int ptrdiff_t;
# 213 "/opt/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/include/stddef.h" 3 4
typedef unsigned int size_t;
# 49
"/opt/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/../../../../include/c++/3.4.1/cstddef"
2 3
namespace std
{
using ::ptrdiff_t;
using ::size_t;
}
# 2 "040718a.cc" 2
struct test
{
const char a;
};
int main(int argc, char *argv[])
{
size_t n=(__offsetof__ (reinterpret_cast <size_t> (&reinterpret_cast <char &>
(static_cast<test *> (0)->a))));
}
--
Summary: In C++, offsetof fails with constant member
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P1
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jrh5y6virbl36ay at optonline dot net
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16618
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/16618] [3.4/3.5 regression] offsetof fails with constant member
2004-07-18 17:36 [Bug c++/16618] New: In C++, offsetof fails with constant member jrh5y6virbl36ay at optonline dot net
@ 2004-07-19 14:15 ` bangerth at dealii dot org
2004-08-12 0:34 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2004-07-19 14:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-07-19 14:14 -------
Confirmed. On mainline, we don't use a macro anymore, but __builtin_offsetof,
but surprisingly the message about reinterpret_cast is still there
despite the fact that preprocessed sources don't have that cast there
any more.
This is a regression in 3.4 and mainline against 3.3.x in which it worked.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |rejects-valid
Known to fail| |3.4.0 3.5.0
Known to work| |3.3.4
Last reconfirmed|0000-00-00 00:00:00 |2004-07-19 14:14:59
date| |
Summary|In C++, offsetof fails with |[3.4/3.5 regression]
|constant member |offsetof fails with constant
| |member
Target Milestone|--- |3.4.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16618
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/16618] [3.4/3.5 regression] offsetof fails with constant member
2004-07-18 17:36 [Bug c++/16618] New: In C++, offsetof fails with constant member jrh5y6virbl36ay at optonline dot net
2004-07-19 14:15 ` [Bug c++/16618] [3.4/3.5 regression] " bangerth at dealii dot org
@ 2004-08-12 0:34 ` cvs-commit at gcc dot gnu dot org
2004-08-12 0:43 ` cvs-commit at gcc dot gnu dot org
2004-08-12 0:53 ` mmitchel at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-12 0:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-08-12 00:34 -------
Subject: Bug 16618
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-3_4-branch
Changes by: mmitchel@gcc.gnu.org 2004-08-12 00:34:33
Modified files:
gcc : ChangeLog
gcc/cp : ChangeLog call.c pt.c
gcc/ginclude : stddef.h
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/init: ptrmem1.C
gcc/testsuite/g++.dg/parse: offsetof5.C
gcc/testsuite/g++.dg/template: overload3.C
Log message:
PR c++/16618
* ginclude/stddef.h (offsetof): Refine C++ definition.
PR c++/16853
* call.c (standard_conversion): Do not accept conversions between
pointers to members if the class types are unrelated.
PR c++/16870
* pt.c (tsubst): Just return the unknown_type_node.
PR c++/16853
* g++.dg/init/ptrmem1.C: New test.
PR c++/16618
* g++.dg/parse/offsetof5.C: New test.
PR c++/16870
* g++.dg/template/overload3.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.578&r2=2.2326.2.579
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.141&r2=1.3892.2.142
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.452.2.20&r2=1.452.2.21
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.37&r2=1.816.2.38
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ginclude/stddef.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.20&r2=1.20.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.244&r2=1.3389.2.245
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/ptrmem1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/offsetof5.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/overload3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16618
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/16618] [3.4/3.5 regression] offsetof fails with constant member
2004-07-18 17:36 [Bug c++/16618] New: In C++, offsetof fails with constant member jrh5y6virbl36ay at optonline dot net
2004-07-19 14:15 ` [Bug c++/16618] [3.4/3.5 regression] " bangerth at dealii dot org
2004-08-12 0:34 ` cvs-commit at gcc dot gnu dot org
@ 2004-08-12 0:43 ` cvs-commit at gcc dot gnu dot org
2004-08-12 0:53 ` mmitchel at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-12 0:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-08-12 00:43 -------
Subject: Bug 16618
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: mmitchel@gcc.gnu.org 2004-08-12 00:43:47
Modified files:
gcc/cp : ChangeLog call.c parser.c pt.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/init: ptrmem1.C
gcc/testsuite/g++.dg/parse: offsetof5.C
gcc/testsuite/g++.dg/template: overload3.C
Log message:
PR c++/16853
* call.c (standard_conversion): Do not accept conversions between
pointers to members if the class types are unrelated.
PR c++/16618
* parser.c (cp_parser_builtin_offsetof): Cast to "const volatile
char &" instead of just "char &".
PR c++/16870
* pt.c (tsubst): Just return the unknown_type_node.
PR c++/16853
* g++.dg/init/ptrmem1.C: New test.
PR c++/16618
* g++.dg/parse/offsetof5.C: New test.
PR c++/16870
* g++.dg/template/overload3.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4270&r2=1.4271
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.498&r2=1.499
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.234&r2=1.235
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.902&r2=1.903
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4119&r2=1.4120
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/ptrmem1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/offsetof5.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/overload3.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16618
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/16618] [3.4/3.5 regression] offsetof fails with constant member
2004-07-18 17:36 [Bug c++/16618] New: In C++, offsetof fails with constant member jrh5y6virbl36ay at optonline dot net
` (2 preceding siblings ...)
2004-08-12 0:43 ` cvs-commit at gcc dot gnu dot org
@ 2004-08-12 0:53 ` mmitchel at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-12 0:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-08-12 00:53 -------
Fixed in GCC 3.4.2.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16618
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-08-12 0:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-18 17:36 [Bug c++/16618] New: In C++, offsetof fails with constant member jrh5y6virbl36ay at optonline dot net
2004-07-19 14:15 ` [Bug c++/16618] [3.4/3.5 regression] " bangerth at dealii dot org
2004-08-12 0:34 ` cvs-commit at gcc dot gnu dot org
2004-08-12 0:43 ` cvs-commit at gcc dot gnu dot org
2004-08-12 0:53 ` mmitchel at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).