NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/53081: __BITMAP_* bitops macros broken with gcc 6.4

>Number:         53081
>Category:       toolchain
>Synopsis:       __BITMAP_* bitops macros broken with gcc 6.4
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 08 09:30:00 +0000 2018
>Originator:     Martin Husemann
>Release:        NetBSD 8.99.12
The NetBSD Foundation, Inc.
System: NetBSD 8.99.12 NetBSD 8.99.12 (WHOEVER) #212: Mon Mar 5 08:13:25 CET 2018 sparc64
Architecture: sparc64
Machine: sparc64

The example from bitmap(3) is broken when compiled with gcc 6.4. This
also breaks the ASID storage of the common pmap, and makes for example
the evbmips64-eb ERLITE unbootable.


Test program:

#include <stdio.h>
#include <sys/types.h>
#include <sys/bitops.h>

	__BITMAP_TYPE(,unsigned long, 256) bitmap;

	// clear the whole bitmap

	// set a single bit
	__BITMAP_SET(0, &bitmap);

	// show all bits that are set
	for (size_t i = 0; i < 256; i++) {
		if (!__BITMAP_ISSET(i, &bitmap))
		printf("bit %zu is set\n", i);

	// dump whole bitmap for examination
	for (size_t i = 0; i < __arraycount(bitmap._b); i++)
		printf("%zu: %016lx\n", i, bitmap._b[i]);

	return 0;

Compile with -Wall -O2 and run:

bit 0 is set
bit 32 is set
0: 0000000000000001
1: 0000000000000000
2: 0000000000000000
3: 0000000000000000

As you can see, the bitmap state itself is correct, but the __BITMAP_ISSET()
macros gives a false postive for bit 32.

This happens at least on mips64eb and sparc64.


Home | Main Index | Thread Index | Old Index