C++:i586-pc-linux-gnu: macro tolower() contains braces
David J. Dooling
d-doolingATnwu.edu
Fri Sep 17 15:40:00 GMT 1999
Note: I am not on the mailing list (re: volume too high) but did
search the gcc-bugs mailing list and did not find anything like this.
Brief description:
When compiled with optimization (-O2) the tolower() function from
<cctype> is replaced with a macro expansion which contains braces.
The compiler warns ISO/ANSI C++ does no allow braces in expressions.
The error only appears when the -O2 (or higher) flag is used in
conjunction with `-ansi -pedantic'. Only a warning is issued.
gcc version: gcc version 2.95 19990728 (release)
architecture: i586-pc-linux-gnu
command line and output:
$ g++ -v --save-temps -O2 -ansi -pedantic tolower.cc
Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/specs
gcc version 2.95 19990728 (release)
/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -trigraphs -D__STRICT_ANSI__ -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -D__OPTIMIZE__ -pedantic -Acpu(i386) -Amachine(i386) -D__i386 -D__i386__ -D__i586 -D__i586__ -D__pentium -D__pentium__ tolower.cc tolower.ii
GNU CPP version 2.95 19990728 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/../../../../include/g++-3
/usr/local/include
/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/../../../../i586-pc-linux-gnu/include
/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/cc1plus tolower.ii -quiet -dumpbase tolower.cc -O2 -pedantic -ansi -version -o tolower.s
GNU C++ version 2.95 19990728 (release) (i586-pc-linux-gnu) compiled by GNU C version 2.95 19990728 (release).
tolower.cc: In function `int main()':
tolower.cc:6: warning: ANSI C++ forbids braced-groups within expressions
as -V -Qy -o tolower.o tolower.s
GNU assembler version 2.9.1 (i386-redhat-linux), using BFD version 2.9.1.0.23
/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/crtbegin.o -L/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95 -L/usr/local/lib tolower.o -lstdc++ -lm -lgcc -lc -lgcc /usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/crtend.o /usr/lib/crtn.o
--- end output ---
here are the files (search ``==='' to get to next file)
files included (in order): tolower.cc tolower.ii
=== tolower.cc ===
#include <cctype>
int
main()
{
char a = tolower('A');
return 0;
}
=== tolower.ii ===
# 1 "tolower.cc"
# 1 "/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/../../../../include/g++-3/cctype" 1 3
# 1 "/usr/include/ctype.h" 1 3
# 1 "/usr/include/features.h" 1 3
# 137 "/usr/include/features.h" 3
# 165 "/usr/include/features.h" 3
# 195 "/usr/include/features.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 71 "/usr/include/sys/cdefs.h" 3
# 103 "/usr/include/sys/cdefs.h" 3
# 249 "/usr/include/features.h" 2 3
# 1 "/usr/include/gnu/stubs.h" 1 3
# 277 "/usr/include/features.h" 2 3
# 26 "/usr/include/ctype.h" 2 3
# 1 "/usr/include/bits/types.h" 1 3
# 1 "/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/include/stddef.h" 1 3
# 19 "/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/include/stddef.h" 3
# 61 "/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/include/stddef.h" 3
# 131 "/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/include/stddef.h" 3
typedef unsigned int size_t;
# 271 "/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/include/stddef.h" 3
# 283 "/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/include/stddef.h" 3
# 317 "/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/include/stddef.h" 3
# 29 "/usr/include/bits/types.h" 2 3
typedef unsigned char __u_char;
typedef unsigned short __u_short;
typedef unsigned int __u_int;
typedef unsigned long __u_long;
__extension__ typedef unsigned long long int __u_quad_t;
__extension__ typedef long long int __quad_t;
# 48 "/usr/include/bits/types.h" 3
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;
__extension__ typedef signed long long int __int64_t;
__extension__ typedef unsigned long long int __uint64_t;
typedef __quad_t *__qaddr_t;
typedef __u_quad_t __dev_t;
typedef __u_int __uid_t;
typedef __u_int __gid_t;
typedef __u_long __ino_t;
typedef __u_int __mode_t;
typedef __u_int __nlink_t;
typedef long int __off_t;
typedef __quad_t __loff_t;
typedef int __pid_t;
typedef int __ssize_t;
typedef long int __rlim_t;
typedef __quad_t __rlim64_t;
typedef __u_int __id_t;
typedef struct
{
int __val[2];
} __fsid_t;
typedef int __daddr_t;
typedef char *__caddr_t;
typedef long int __time_t;
typedef long int __swblk_t;
typedef long int __clock_t;
typedef unsigned long int __fd_mask;
typedef struct
{
__fd_mask __fds_bits[1024 / (8 * sizeof (__fd_mask)) ];
} __fd_set;
typedef int __key_t;
typedef unsigned short int __ipc_pid_t;
typedef __u_long __blkcnt_t;
typedef __u_quad_t __blkcnt64_t;
typedef long int __fsblkcnt_t;
typedef __quad_t __fsblkcnt64_t;
typedef __u_long __fsfilcnt_t;
typedef __u_quad_t __fsfilcnt64_t;
typedef __u_long __ino64_t;
typedef __loff_t __off64_t;
typedef int __t_scalar_t;
typedef unsigned int __t_uscalar_t;
typedef int __intptr_t;
# 27 "/usr/include/ctype.h" 2 3
extern "C" {
# 1 "/usr/include/endian.h" 1 3
# 1 "/usr/include/bits/endian.h" 1 3
# 35 "/usr/include/endian.h" 2 3
# 40 "/usr/include/ctype.h" 2 3
enum
{
_ISupper = (( 0 ) < 8 ? ((1 << ( 0 )) << 8) : ((1 << ( 0 )) >> 8)) ,
_ISlower = (( 1 ) < 8 ? ((1 << ( 1 )) << 8) : ((1 << ( 1 )) >> 8)) ,
_ISalpha = (( 2 ) < 8 ? ((1 << ( 2 )) << 8) : ((1 << ( 2 )) >> 8)) ,
_ISdigit = (( 3 ) < 8 ? ((1 << ( 3 )) << 8) : ((1 << ( 3 )) >> 8)) ,
_ISxdigit = (( 4 ) < 8 ? ((1 << ( 4 )) << 8) : ((1 << ( 4 )) >> 8)) ,
_ISspace = (( 5 ) < 8 ? ((1 << ( 5 )) << 8) : ((1 << ( 5 )) >> 8)) ,
_ISprint = (( 6 ) < 8 ? ((1 << ( 6 )) << 8) : ((1 << ( 6 )) >> 8)) ,
_ISgraph = (( 7 ) < 8 ? ((1 << ( 7 )) << 8) : ((1 << ( 7 )) >> 8)) ,
_ISblank = (( 8 ) < 8 ? ((1 << ( 8 )) << 8) : ((1 << ( 8 )) >> 8)) ,
_IScntrl = (( 9 ) < 8 ? ((1 << ( 9 )) << 8) : ((1 << ( 9 )) >> 8)) ,
_ISpunct = (( 10 ) < 8 ? ((1 << ( 10 )) << 8) : ((1 << ( 10 )) >> 8)) ,
_ISalnum = (( 11 ) < 8 ? ((1 << ( 11 )) << 8) : ((1 << ( 11 )) >> 8))
};
extern __const unsigned short int *__ctype_b;
extern __const __int32_t *__ctype_tolower;
extern __const __int32_t *__ctype_toupper;
extern int isalnum (int) throw () ;
extern int isalpha (int) throw () ;
extern int iscntrl (int) throw () ;
extern int isdigit (int) throw () ;
extern int islower (int) throw () ;
extern int isgraph (int) throw () ;
extern int isprint (int) throw () ;
extern int ispunct (int) throw () ;
extern int isspace (int) throw () ;
extern int isupper (int) throw () ;
extern int isxdigit (int) throw () ;
extern int tolower (int __c) throw () ;
extern int toupper (int __c) throw () ;
# 125 "/usr/include/ctype.h" 3
extern __inline int
tolower (int __c) throw ()
{
return __c >= -128 && __c < 256 ? __ctype_tolower[__c] : __c;
}
extern __inline int
toupper (int __c) throw ()
{
return __c >= -128 && __c < 256 ? __ctype_toupper[__c] : __c;
}
# 182 "/usr/include/ctype.h" 3
# 272 "/usr/include/ctype.h" 3
}
# 6 "/usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.95/../../../../include/g++-3/cctype" 2 3
# 1 "tolower.cc" 2
int
main()
{
char a = ({ int __res; if (sizeof ( 'A' ) > 1) { if (__builtin_constant_p ( 'A' )) { int __c = ( 'A' ); __res = __c < -128 || __c > 255 ? __c : __ctype_tolower [__c]; } else __res = tolower ( 'A' ); } else __res = __ctype_tolower [(int) ( 'A' )]; __res; }) ;
return 0;
}
More information about the Gcc-bugs
mailing list