[ARM] stdint.h should not rely on wchar_t being defined

Bug #1438797 reported by James Greenhalgh
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
eglibc (Ubuntu)
New
Undecided
Unassigned

Bug Description

This patch to eglibc from debian (which is applied for Ubuntu 12.04):
  ( https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=arm-eabi-wchar.patch;att=1;bug=444580 )

Gives this definition for __WCHAR_MAX in bits/wchar.h

#define __WCHAR_MAX ( (wchar_t) - 1 )

This then propagates to WCHAR_MAX from stdint.h:

# define WCHAR_MAX __WCHAR_MAX

The problem is that this introduces a requirement that stddef.h must be included before stdint.h in order to make the definition of wchar_t available.

In a conforming C implimentation, this should be valid:

#include "stdint.h"
#include "stdio.h"

unsigned int
foo (void)
{
  return (unsigned int) WCHAR_MAX;
}

Currently this will report:

gcc foo.c
foo.c: In function ‘foo’:
foo.c:7:25: error: ‘wchar_t’ undeclared (first use in this function)
foo.c:7:25: note: each undeclared identifier is reported only once for each function it appears in

The easiest fix would be to take the more modern, portable definition of WCHAR_MAX/__WCHAR_MAX from Ubuntu 14.04's glibc.

Revision history for this message
James Greenhalgh (james-greenhalgh-y) wrote :

This causes:

  FAIL: gcc.dg/c99-stdint-1.c (test for excess errors)
  FAIL: gcc.dg/c99-stdint-7.c (test for excess errors)

In the GCC testsuite, when testing a native arm-none-linux-gnueabihf toolchain under a Ubuntu 12.04 system.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.