From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9634 invoked by alias); 23 Jun 2008 16:09:06 -0000 Received: (qmail 8767 invoked by uid 48); 23 Jun 2008 16:08:22 -0000 Date: Mon, 23 Jun 2008 16:09:00 -0000 Subject: [Bug c++/36607] New: Incorrect type diagnostic on substracting casted char pointers X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rschiele at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-06/txt/msg01366.txt.bz2 The following little code sample does no longer compile with 4.3 or higher: struct a {}; void b() { int a::*m; a *c; int p = reinterpret_cast(&(c->*m)) - reinterpret_cast(c); } Instead the compiler emits the error message: bad.cc: In function ‘void b()’: bad.cc:5: error: aggregate value used where an integer was expected Though it is clear that this code sample is not perfectly valid according to the C++ standard since "reinterpret_cast(&(c->*m))" and "reinterpret_cast(c)" are not part of the same array I would not expect this kind of behavior since the claim of the compiler that there is something wrong with types is completely bogus. Rewriting the code like the following makes the compiler accepting it again: struct a {}; void b() { int a::*m; a *c; char* d = reinterpret_cast(&(c->*m)); char* e = reinterpret_cast(c); int p = d - e; } -- Summary: Incorrect type diagnostic on substracting casted char pointers Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rschiele at gmail dot com GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36607