------- Comment #1 from eblot dot ml at gmail dot com  2010-05-30 10:36 -------
Update: This is a C++ only bug, the same code in C language does not exhibit
the bug:


# --- Building as C language ---
$> arm-eabi-gcc -c -O2 -mcpu=arm926ej-s -o fopen.o -x c fopen.c -Wextra
-save-temps && cat fopen.s
        .cpu arm926ej-s
        .fpu softvfp
        .eabi_attribute 20, 1
        .eabi_attribute 21, 1
        .eabi_attribute 23, 3
        .eabi_attribute 24, 1
        .eabi_attribute 25, 1
        .eabi_attribute 26, 1
        .eabi_attribute 30, 2
        .eabi_attribute 18, 4
        .file   "fopen.c"
        .text
        .align  2
        .global open_file
        .type   open_file, %function
open_file:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        cmp     r1, #3
        ldrls   r3, .L4
        movhi   r1, #0
        ldrls   r1, [r3, r1, asl #2]
        b       open
.L5:
        .align  2
.L4:
        .word   .LANCHOR0
        .size   open_file, .-open_file
        .section        .rodata
        .align  2
        .set    .LANCHOR0,. + 0
        .type   CSWTCH.1, %object
        .size   CSWTCH.1, 16
CSWTCH.1:
        .word   1
        .word   74
        .word   3
        .word   75
        .ident  "GCC: 4.5.0"

# --- Building as C++ language ---
arm-eabi-gcc -c -O2 -mcpu=arm926ej-s -o fopen.o -x c++ fopen.c -Wextra
-save-temps && cat fopen.s
fopen.c: In function ‘void open_file(const char*, OpenMode)’:
fopen.c:16:6: warning: comparison always true due to limited range of data type
        .cpu arm926ej-s
        .fpu softvfp
        .eabi_attribute 20, 1
        .eabi_attribute 21, 1
        .eabi_attribute 23, 3
        .eabi_attribute 24, 1
        .eabi_attribute 25, 1
        .eabi_attribute 26, 1
        .eabi_attribute 30, 2
        .eabi_attribute 18, 4
        .file   "fopen.c"
        .text
        .align  2
        .global _Z9open_filePKc8OpenMode
        .type   _Z9open_filePKc8OpenMode, %function
_Z9open_filePKc8OpenMode:
        .fnstart
.LFB0:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        ldr     r3, .L2
        sub     r1, r1, #1
        and     r1, r1, #255
        ldr     r1, [r3, r1, asl #2]
        b       _Z4openPKci
.L3:
        .align  2
.L2:
        .word   .LANCHOR0
.LFE0:
        .cantunwind
        .fnend
        .size   _Z9open_filePKc8OpenMode, .-_Z9open_filePKc8OpenMode
        .section        .rodata
        .align  2
        .set    .LANCHOR0,. + 0
        .type   CSWTCH.1, %object
        .size   CSWTCH.1, 12
CSWTCH.1:
        .word   74
        .word   3
        .word   75
        .ident  "GCC: 4.5.0"


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44328

Reply via email to