Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 May 2007 11:37:20 +0400
From:      "Yuriy Tsibizov" <Yuriy.Tsibizov@gfk.ru>
To:        "Julian Elischer" <julian@elischer.org>, "Hans Petter Selasky" <hselasky@c2i.net>
Cc:        freebsd-current@freebsd.org
Subject:   RE: vrp bitfield miscompilation (WAS: [Regression] snd_emu10k1	doesn't work after GCC 4.2 upgrade)
Message-ID:  <78664C02FF341B4FAC63E561846E3BCC0A1108@ex.hhp.local>
In-Reply-To: <465A7F1E.5000109@elischer.org>
References:  <009501c79fdf$19e25880$1e00000a@hhp.local>	<78664C02FF341B4FAC63E561846E3BCC0A1103@ex.hhp.local><200705280857.12035.hselasky@c2i.net> <465A7F1E.5000109@elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> >>> See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D32100
> >> Use of following variables _can_ be affected by above=20
> miscompilation
> >> (these are signed single-bit variables):
> >>
> >> amd64/amd64/mp_machdep.c:	int	cpu_present:1;
> >> amd64/amd64/mp_machdep.c:	int	cpu_bsp:1;
> >> amd64/amd64/mp_machdep.c:	int	cpu_disabled:1;
> >> dev/acpica/acpi_pci_link.c:	int	l_routed:1;
> >> dev/acpica/acpi_pci_link.c:	int	l_isa_irq:1;
> >> dev/sound/isa/ess.c:    	int type, duplex:1, newspeed:1;
> >> dev/sound/pci/emu10k1.c:	int b16:1, stereo:1, busy:1, running:1,
> >> ismaster:1;
> >> dev/sound/pci/solo.c:    	int simplex_dir, type, duplex:1,
> >> newspeed:1, dmasz[2];
> >> dev/puc/puc.c:	int		p_hasintr:1;
> >> dev/puc/puc_bfe.h:	int		sc_fastintr:1;
> >> dev/puc/puc_bfe.h:	int		sc_leaving:1;
> >> dev/puc/puc_bfe.h:	int		sc_polled:1;
> >> dev/rp/rpvar.h:	int			rp_rts_iflow:1;
> >> dev/rp/rpvar.h:	int			rp_disable_writes:1;
> >> dev/rp/rpvar.h:	int			rp_cts:1;
> >> dev/rp/rpvar.h:	int			rp_waiting:1;
> >> dev/rp/rpvar.h:	int			rp_xmit_stopped:1;
> >> dev/scc/scc_bfe.h:	int		m_attached:1;
> >> dev/scc/scc_bfe.h:	int		m_fastintr:1;
> >> dev/scc/scc_bfe.h:	int		m_hasintr:1;
> >> dev/scc/scc_bfe.h:	int		m_probed:1;
> >> dev/scc/scc_bfe.h:	int		m_sysdev:1;
> >> dev/scc/scc_bfe.h:	int		ch_enabled:1;
> >> dev/scc/scc_bfe.h:	int		ch_sysdev:1;
> >> dev/scc/scc_bfe.h:	int		sc_fastintr:1;
> >> dev/scc/scc_bfe.h:	int		sc_leaving:1;
> >> dev/scc/scc_bfe.h:	int		sc_polled:1;
> >> dev/uart/uart_bus.h:	int		sc_callout:1;=09
> /* This UART is
> >> opened for callout. */
> >> dev/uart/uart_bus.h:	int		sc_fastintr:1;=09
> /* This UART
> >> uses fast interrupts. */
> >> dev/uart/uart_bus.h:	int		sc_hwiflow:1;=09
> /* This UART has
> >> HW input flow ctl. */
> >> dev/uart/uart_bus.h:	int		sc_hwoflow:1;=09
> /* This UART has
> >> HW output flow ctl. */
> >> dev/uart/uart_bus.h:	int		sc_leaving:1;=09
> /* This UART is
> >> going away. */
> >> dev/uart/uart_bus.h:	int		sc_opened:1;=09
> /* This UART is
> >> open for business. */
> >> dev/uart/uart_bus.h:	int		sc_polled:1;=09
> /* This UART has
> >> no interrupts. */
> >> dev/uart/uart_bus.h:	int		sc_txbusy:1;=09
> /* This UART is
> >> transmitting. */
> >> fs/pseudofs/pseudofs_internal.h:	int		 pvd_dead:1;
> >> geom/part/g_part.h:	int		gpe_created:1;=09
> /* Entry is
> >> newly created. */
> >> geom/part/g_part.h:	int		gpe_deleted:1;=09
> /* Entry has
> >> been deleted. */
> >> geom/part/g_part.h:	int		gpe_modified:1;=09
> /* Entry has
> >> been modified. */
> >> geom/part/g_part.h:	int		gpt_isleaf:1;=09
> /* Cannot be
> >> sub-partitioned. */
> >> geom/part/g_part.h:	int		gpt_created:1;	/* Newly
> >> created. */
> >> geom/part/g_part.h:	int		gpt_modified:1;=09
> /* Table changes
> >> have been made. */
> >> geom/part/g_part.h:	int		gpt_opened:1;=09
> /* Permissions
> >> obtained. */
> >> i386/i386/mp_machdep.c:	int	cpu_present:1;
> >> i386/i386/mp_machdep.c:	int	cpu_bsp:1;
> >> i386/i386/mp_machdep.c:	int	cpu_disabled:1;
> >> i386/include/npx.h:	int	fp_sgn:1;	/*=20
> mantissa sign */
> >> sparc64/pci/psycho.c:		int apb:1;
> >> sparc64/pci/psycho.c:		int ppb:1;
> >>
> >> I can't say that there _is_ a miscompilation related to=20
> all variables in
> >> this list.
> >>
> >> Should most of them (I'm not shure for fp_sign) be changed=20
> to unsigned
> >> int? With (signed) int these flags have values of (-1;0),=20
> with unsigned
> >> int they will use more obvious (0;1) values.
> >>
> >>
> >> Yuriy.
> >=20
> > Interesting find. Another issue:
> >=20
> > I've seen that the compile will round the memory size of a=20
> bit-fields down to=20
> > the nearest byte, if you turn on optimization. I think you should=20
> > use "uint8_t".
>=20
> My memory is that bitfields are only defined as parts of an 'int'
> in the standard and that using anything else is a gcc 'feature'.
>=20
> This is a 14 year old memory (from my SCSI days) so it may not be true
> now.

>From ISO/IEC 9899 (C99): "A bit-field shall have a type that is a
qualified or unqualified version of _Bool, signed
int, unsigned int, or some other implementation-defined type."

Yuriy.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?78664C02FF341B4FAC63E561846E3BCC0A1108>