Thread: gcc-4.1.2 miscompiles setedit from CVS
Brought to you by:
set
From: Witold F. <wi...@po...> - 2006-08-20 11:39:41
Attachments:
setedit-gcc4.patch
|
gcc-4.1.2 miscompiles setedit from CVS. The first error is trivial to fix. The patch in the attachment. The second error is related to packed attribute in setedit/runprog.cc: g++ -I../include -I../setedit/include -I../settvuti/include -I../sdg/include -I../infview/include -I../../tvision/include -I../extra -I../easydiag -I../librhuti -I../mp3 -I../calcu -I../holidays -DFOR_EDITOR -O2 -pipe -c ../setedit/runprog.cc -o obj/runprog.o ../setedit/runprog.cc: In function 'void ConfigureRunCommand()': ../setedit/runprog.cc:95: warning: 'packed' attribute ignored for field of type 'char [256]' ../setedit/runprog.cc:99: warning: 'packed' attribute ignored for field of type 'char [4]' ../setedit/runprog.cc:116: error: cannot bind packed field 'box.ConfigureRunCommand()::<anonymous struct>::tl.TListBoxRec::selection' to 'ccIndex&' -- Witek |
From: Salvador E. T. <sal...@in...> - 2006-08-23 16:37:23
|
On 20/08/06 07:45, Witold Filipczyk wrote: >gcc-4.1.2 miscompiles setedit from CVS. >The first error is trivial to fix. The patch in the attachment. > > Ok, I'm applying it. >The second error is related to packed attribute in setedit/runprog.cc: > >g++ -I../include -I../setedit/include -I../settvuti/include >-I../sdg/include -I../infview/include -I../../tvision/include -I../extra >-I../easydiag -I../librhuti -I../mp3 -I../calcu -I../holidays >-DFOR_EDITOR -O2 -pipe -c ../setedit/runprog.cc -o obj/runprog.o >../setedit/runprog.cc: In function 'void ConfigureRunCommand()': >../setedit/runprog.cc:95: warning: 'packed' attribute ignored for field >of type 'char [256]' >../setedit/runprog.cc:99: warning: 'packed' attribute ignored for field >of type 'char [4]' >../setedit/runprog.cc:116: error: cannot bind packed field >'box.ConfigureRunCommand()::<anonymous >struct>::tl.TListBoxRec::selection' to 'ccIndex&' > > I don't understand it. Sure that char[4] is already 32 bits aligned but I don't want to assume that it means that this is also "aligned" for 64 and 128 bits machines. So that's a silly warning. Is the error related to the warning? what happends if you remove the packed attribute to the above mentioned members? SET P.S. Be patient with my next reply! more in another mail |
From: Baurzhan I. <ib...@at...> - 2006-08-23 19:41:34
|
On Wed, Aug 23, 2006 at 01:36:50PM -0300, Salvador Eduardo Tropea wrote: > >The second error is related to packed attribute in setedit/runprog.cc: > > > >g++ -I../include -I../setedit/include -I../settvuti/include > >-I../sdg/include -I../infview/include -I../../tvision/include -I../extra > >-I../easydiag -I../librhuti -I../mp3 -I../calcu -I../holidays > >-DFOR_EDITOR -O2 -pipe -c ../setedit/runprog.cc -o obj/runprog.o > >../setedit/runprog.cc: In function 'void ConfigureRunCommand()': > >../setedit/runprog.cc:95: warning: 'packed' attribute ignored for field > >of type 'char [256]' > >../setedit/runprog.cc:99: warning: 'packed' attribute ignored for field > >of type 'char [4]' > >../setedit/runprog.cc:116: error: cannot bind packed field > >'box.ConfigureRunCommand()::<anonymous > >struct>::tl.TListBoxRec::selection' to 'ccIndex&' > > I don't understand it. Sure that char[4] is already 32 bits aligned but > I don't want to assume that it means that this is also "aligned" for 64 > and 128 bits machines. So that's a silly warning. The warning is not silly, it says that the compiler ignores the attribute. __attribute__((packed)) packs the field itself (which in case of char[] is already packed), it doesn't have any impact on the surrounding fields. You probably want the following (untested): diff -Naurp setedit.orig/setedit/runprog.cc setedit/setedit/runprog.cc --- setedit.orig/setedit/runprog.cc 2004-08-11 19:34:06.000000000 +0200 +++ setedit/setedit/runprog.cc 2006-08-23 21:28:19.000000000 +0200 @@ -92,13 +92,13 @@ void ConfigureRunCommand(void) #pragma pack(1) struct { - char ComAux[maxCommand] __attribute__((packed)); - uint32 Options __attribute__((packed)); - uint32 OpsScroll __attribute__((packed)); - uint32 OpsScrHz __attribute__((packed)); - char Lines[4] __attribute__((packed)); - TListBoxRec tl __attribute__((packed)); - } box; + char ComAux[maxCommand]; + uint32 Options; + uint32 OpsScroll; + uint32 OpsScrHz; + char Lines[4]; + TListBoxRec tl; + } __attribute__((packed)) box; #pragma pack() strcpy(box.ComAux,Command); box.Options=Options & (~edsmScrollMask); > Is the error related to the warning? what happends if you remove the > packed attribute to the above mentioned members? I'd like to hear an explanation if you find it. At first I thought that box.ConfigureRunCommand()::<anonymous struct>::tl.TListBoxRec::selection is packed, and ccIndex is not, thus the error. However, this doesn't explain why the problem goes away with the fix from Witek. With kind regards, Baurzhan. |
From: Witold F. <wi...@po...> - 2006-08-26 14:39:37
|
On Wed, Aug 23, 2006 at 09:40:50PM +0200, Baurzhan Ismagulov wrote: > On Wed, Aug 23, 2006 at 01:36:50PM -0300, Salvador Eduardo Tropea wrote: > > >The second error is related to packed attribute in setedit/runprog.cc: > > > > > >g++ -I../include -I../setedit/include -I../settvuti/include > > >-I../sdg/include -I../infview/include -I../../tvision/include -I../extra > > >-I../easydiag -I../librhuti -I../mp3 -I../calcu -I../holidays > > >-DFOR_EDITOR -O2 -pipe -c ../setedit/runprog.cc -o obj/runprog.o > > >../setedit/runprog.cc: In function 'void ConfigureRunCommand()': > > >../setedit/runprog.cc:95: warning: 'packed' attribute ignored for field > > >of type 'char [256]' > > >../setedit/runprog.cc:99: warning: 'packed' attribute ignored for field > > >of type 'char [4]' > > >../setedit/runprog.cc:116: error: cannot bind packed field > > >'box.ConfigureRunCommand()::<anonymous > > >struct>::tl.TListBoxRec::selection' to 'ccIndex&' > > > > I don't understand it. Sure that char[4] is already 32 bits aligned but > > I don't want to assume that it means that this is also "aligned" for 64 > > and 128 bits machines. So that's a silly warning. > > The warning is not silly, it says that the compiler ignores the > attribute. __attribute__((packed)) packs the field itself (which in case > of char[] is already packed), it doesn't have any impact on the > surrounding fields. You probably want the following (untested): > > diff -Naurp setedit.orig/setedit/runprog.cc setedit/setedit/runprog.cc > --- setedit.orig/setedit/runprog.cc 2004-08-11 19:34:06.000000000 +0200 > +++ setedit/setedit/runprog.cc 2006-08-23 21:28:19.000000000 +0200 > @@ -92,13 +92,13 @@ void ConfigureRunCommand(void) > #pragma pack(1) > struct > { > - char ComAux[maxCommand] __attribute__((packed)); > - uint32 Options __attribute__((packed)); > - uint32 OpsScroll __attribute__((packed)); > - uint32 OpsScrHz __attribute__((packed)); > - char Lines[4] __attribute__((packed)); > - TListBoxRec tl __attribute__((packed)); > - } box; > + char ComAux[maxCommand]; > + uint32 Options; > + uint32 OpsScroll; > + uint32 OpsScrHz; > + char Lines[4]; > + TListBoxRec tl; > + } __attribute__((packed)) box; > #pragma pack() > strcpy(box.ComAux,Command); > box.Options=Options & (~edsmScrollMask); It works with this patch. Is it the right way? -- Witek |
From: Salvador E. T. <sal...@in...> - 2007-05-16 20:25:14
|
Just to mention that gcc 4.1.x compilations issues were solved in revision 1244 of the editor (2007/04/18 19:15:17). SET On 23/08/06 16:40, Baurzhan Ismagulov wrote: > On Wed, Aug 23, 2006 at 01:36:50PM -0300, Salvador Eduardo Tropea wrote: > >>> The second error is related to packed attribute in setedit/runprog.cc: >>> >>> g++ -I../include -I../setedit/include -I../settvuti/include >>> -I../sdg/include -I../infview/include -I../../tvision/include -I../extra >>> -I../easydiag -I../librhuti -I../mp3 -I../calcu -I../holidays >>> -DFOR_EDITOR -O2 -pipe -c ../setedit/runprog.cc -o obj/runprog.o >>> ../setedit/runprog.cc: In function 'void ConfigureRunCommand()': >>> ../setedit/runprog.cc:95: warning: 'packed' attribute ignored for field >>> of type 'char [256]' >>> ../setedit/runprog.cc:99: warning: 'packed' attribute ignored for field >>> of type 'char [4]' >>> ../setedit/runprog.cc:116: error: cannot bind packed field >>> 'box.ConfigureRunCommand()::<anonymous >>> struct>::tl.TListBoxRec::selection' to 'ccIndex&' >>> >> I don't understand it. Sure that char[4] is already 32 bits aligned but >> I don't want to assume that it means that this is also "aligned" for 64 >> and 128 bits machines. So that's a silly warning. >> > > The warning is not silly, it says that the compiler ignores the > attribute. __attribute__((packed)) packs the field itself (which in case > of char[] is already packed), it doesn't have any impact on the > surrounding fields. You probably want the following (untested): > > diff -Naurp setedit.orig/setedit/runprog.cc setedit/setedit/runprog.cc > --- setedit.orig/setedit/runprog.cc 2004-08-11 19:34:06.000000000 +0200 > +++ setedit/setedit/runprog.cc 2006-08-23 21:28:19.000000000 +0200 > @@ -92,13 +92,13 @@ void ConfigureRunCommand(void) > #pragma pack(1) > struct > { > - char ComAux[maxCommand] __attribute__((packed)); > - uint32 Options __attribute__((packed)); > - uint32 OpsScroll __attribute__((packed)); > - uint32 OpsScrHz __attribute__((packed)); > - char Lines[4] __attribute__((packed)); > - TListBoxRec tl __attribute__((packed)); > - } box; > + char ComAux[maxCommand]; > + uint32 Options; > + uint32 OpsScroll; > + uint32 OpsScrHz; > + char Lines[4]; > + TListBoxRec tl; > + } __attribute__((packed)) box; > #pragma pack() > strcpy(box.ComAux,Command); > box.Options=Options & (~edsmScrollMask); > > > >> Is the error related to the warning? what happends if you remove the >> packed attribute to the above mentioned members? >> > > I'd like to hear an explanation if you find it. At first I thought that > box.ConfigureRunCommand()::<anonymous struct>::tl.TListBoxRec::selection > is packed, and ccIndex is not, thus the error. However, this doesn't > explain why the problem goes away with the fix from Witek. > > > With kind regards, > Baurzhan. > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Setedit-users mailing list > Set...@li... > https://lists.sourceforge.net/lists/listinfo/setedit-users > > -- Salvador Eduardo Tropea (SET). (Electronics Engineer) Visit my home page: http://welcome.to/SetSoft or http://www.geocities.com/SiliconValley/Vista/6552/ Alternative e-mail: se...@co... se...@ie... Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA Phone: +(5411) 4759 0013 |