This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20185] New: assignment error in inline function
- From: "dirk at cle-mens dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Feb 2005 10:29:39 -0000
- Subject: [Bug c++/20185] New: assignment error in inline function
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
// Postet by dirk@cle-mens.de
// Compiler Error found:
// gcc (GCC) 3.3.4 (pre 3.3.5 20040809)
// under SuSE Linux kernel 2.6.8-24.10-default (i386)
//
// This Bug is a little bit different in relation to bug #20184
//
// If this littel programm is compiled with the option -O2
// the assignment in the inline function was wrong.
// If I remove the 'inline' the result is correct.
//
// Compiled with: g++ -Wall error.cpp
// -> OK, printout = 0000000000000000
//
// Compiled with: g++ -Wall -O2 error.cpp
// -> ERROR, printout = 0804836d00000000
//
// Compiled with: g++ -Wall -O2 error.cpp,,
// but without 'inline' for func data::data()
// -> OK, printout = 0000000000000000
//
#include <stdlib.h>
#include <stdio.h>
typedef unsigned int uint32;
typedef unsigned long long uint64;
class data
{
public:
uint32 lo;
uint32 hi;
data ( uint32 num );
operator uint64 () const;
};
inline data::data ( uint32 num ) { lo = num; hi = -(num<0); }
inline data::operator uint64 () const { return *(uint64*)this; }
int main()
{
printf("sizeof(uint32)=%d\n",sizeof(uint32));
printf("sizeof(uint64)=%d\n",sizeof(uint64));
printf("sizeof(data) =%d\n", sizeof(data));
uint32 tab[] = { 0,0,0,0,0 };
uint32 *p = tab;
uint64 u64 = data(*p++);
printf("%016llx\n",u64);
}
--
Summary: assignment error in inline function
Product: gcc
Version: 3.3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dirk at cle-mens dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20185