From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 420A13858C78; Tue, 25 Jul 2023 06:49:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 420A13858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690267795; bh=Q5elCawdbLPxfL/GUrlKbCw6wC6BgLRHDe+J2ig31qo=; h=From:To:Subject:Date:From; b=mfkSJBD3Ub+a2Yg/BZwy2z8z4Gr1q1tAf2p2ZcKqGHreZsz7v7kqJoDoAI0iD/sgf zOiTKrZHHQzr2EWd3ork3sMQCPwtZK/RnR3j8e/j8GNWeNLBOn1rStgwPo3GjXwol1 intLZQ4u2zTp+Zaz6urkxL9zYJEiu36vqPGW/lF0= From: "13958014620 at 139 dot com" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBjKysvMTEwNzk4XSBOZXc6IFRoZSByZXVzdWx0IG9mIHNp?= =?UTF-8?B?emVvZiBvcGVyYXRvciBmb2xsb3dlZCB3aXRoIGFuICd1bnNpZ25lZCB0eXBl?= =?UTF-8?B?ZGVmLWVkIGdlbmVyaWMgaW50ZWdlcicgdHlwZSBpcyBhbHdheSA0IGJ5dGVz?= =?UTF-8?B?77yIZXhjZXB0IGNoYXLvvIk=?= Date: Tue, 25 Jul 2023 06:49:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: og12 (devel/omp/gcc-12) X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: 13958014620 at 139 dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110798 Bug ID: 110798 Summary: The reusult of sizeof operator followed with an 'unsigned typedef-ed generic integer' type is alway 4 bytes=EF=BC=88except char=EF=BC=89 Product: gcc Version: og12 (devel/omp/gcc-12) Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: 13958014620 at 139 dot com Target Milestone: --- Some issues arised when doing some tests. The reusult of sizeof operator followed with an 'unsigned typedef-ed generic integer' type is always 4 bytes=EF=BC=88except char=EF=BC=89. The following example had run in fedora 37 OS with gcc_12.3.1 and gcc_13.1.0(compiled myself), both versions of gcc show the same issue. #include int main(int argc, char ** argv){ int ret=3D0; typedef char ch_t; assert( sizeof(unsigned char) =3D=3D 1); //right assert( sizeof(ch_t) =3D=3D 1 ); //right assert( sizeof(unsigned ch_t) =3D=3D 1); //the only one right typedef signed char sch; assert( sizeof(unsigned char) =3D=3D 1); //right assert( sizeof(sch) =3D=3D 1 ); //right assert( sizeof(unsigned sch) =3D=3D 4); //wrong, which should be 1 typedef short sint; assert( sizeof(unsigned short) =3D=3D 2 ); //right assert( sizeof(sint) =3D=3D 2 ); //right assert( sizeof(unsigned sint) =3D=3D 4); //wrong, which should be 8 typedef long lint; assert( sizeof(unsigned long) =3D=3D 8); //right assert( sizeof(lint) =3D=3D 8 ); //right assert( sizeof(unsigned lint) =3D=3D 4); //wrong, which should be 8 typedef long long llint; assert( sizeof(unsigned long long) =3D=3D 8); //right assert( sizeof(llint) =3D=3D 8 ); //right assert( sizeof(unsigned llint) =3D=3D4); //wrong, which should be 8 /* The same errors as:=20 'typedef signed short ssint',=20 'typedef signed long slint',=20 'typedef signed long long sllint',=20 'typedef unsigned short usint',=20 'typedef unsigned long ulint',=20 'typedef unsigned long long ullint',=20 so that seems all sizeof(unsigned ) =3D=3D 4,=20 except typedef char ch_t; */ return ret; } ----------- or a version outputting the result on the terminal ------------= -- #include #include using namespace std; int main(int argc, char ** argv){ int ret=3D0; typedef char ch_t; cout << "typedef char ch_t;"<) = =3D=3D 4, \n\ except typedef char ch_t;" << endl; return ret; } These issues can't reproduce in pure C language with GCC 12 and 13.=