public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66239] New: Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp]
@ 2015-05-21 10:56 maciej.andrzejewski at data dot pl
2015-05-21 15:28 ` [Bug c++/66239] " ramana at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: maciej.andrzejewski at data dot pl @ 2015-05-21 10:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66239
Bug ID: 66239
Summary: Unoptimized sqrt(float or double) returns wrong values
for ARM Cortex-A8 -mfloat-abi=[soft,softfp]
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: maciej.andrzejewski at data dot pl
Target Milestone: ---
Tested both on GCC 4.9.1 (compiled toolchain using crosstool-ng) and 4.9.2
(compiled toolchain using buildroot).
Simple code:
-- CODE --
#include <stdio.h>
#include <cmath>
#include <math.h>
int main( void )
{
double sq3 = 9.1;
double ret3 = sqrtf(sq3);
printf("%f\n", ret3);
float sq4 = 9.1;
double ret4 = sqrtf(sq4);
printf("%f\n", ret4);
double sq1 = 9.1;
double ret1 = sqrt(sq1);
printf("%f\n", ret1);
float sq2 = 9.1;
double ret2 = sqrt(sq2);
printf("%f\n", ret2);
return 0;
}
-- CODE --
compiled with command:
g++ -mcpu=cortex-a8 -march=armv7-a -mtune=cortex-a8 -mfpu=neon
-mthumb-interwork -mfpu=neon -Wall -Wextra -mfloat-abi=softfp
or
g++ -mcpu=cortex-a8 -march=armv7-a -mtune=cortex-a8 -mfpu=neon
-mthumb-interwork -mfpu=neon -Wall -Wextra -mfloat-abi=soft
prints output when run:
-- OUTPUT --
0.000000
0.000000
89884613882771507935772421602449274280826426490922860415370742828850803088708436568909338933268615382725731836148779976703521876921396883553861971381426763394584730974161643341227168116324626810241973964225774272233175406843466371141886318608237834273423597057507238373804952327520531541920130815989439791104.000000
89884613882771507935772421602449274280826426490922860415370742828850803088708436568909338933268615382725731836148779976703521876921396883553861971381426763394584730974161643341227168116324626810241973964225774272233175406843466371141886318608237834273423597057507238373804952327520531541920130815989439791104.000000
-- OUTPUT --
when compiled with added ANY optimization flag (O, O1, O2, O3, Og) prints
proper output:
-- OUTPUT 2 --
3.016621
3.016621
3.016621
3.016621
-- OUTPUT 2 --
*** Additional info ***
g++ --version:
arm-none-linux-gnueabi-g++ (Buildroot 2015.02) 4.9.2
readelf -a a.out:
-- READELF --
macieja@ubuntu:~/Projects/sqrtf$ readelf -a a.out
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0x103d0
Start of program headers: 52 (bytes into file)
Start of section headers: 5012 (bytes into file)
Flags: 0x5000202, has entry point, Version5 EABI,
soft-float ABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 8
Size of section headers: 40 (bytes)
Number of section headers: 29
Section header string table index: 26
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf
Al
[ 0] NULL 00000000 000000 000000 00 0 0
0
[ 1] .interp PROGBITS 00010134 000134 000013 00 A 0 0
1
[ 2] .note.ABI-tag NOTE 00010148 000148 000020 00 A 0 0
4
[ 3] .hash HASH 00010168 000168 000038 04 A 4 0
4
[ 4] .dynsym DYNSYM 000101a0 0001a0 000090 10 A 5 1
4
[ 5] .dynstr STRTAB 00010230 000230 0000d3 00 A 0 0
1
[ 6] .gnu.version VERSYM 00010304 000304 000012 02 A 4 0
2
[ 7] .gnu.version_r VERNEED 00010318 000318 000040 00 A 5 2
4
[ 8] .rel.dyn REL 00010358 000358 000008 08 A 4 0
4
[ 9] .rel.plt REL 00010360 000360 000020 08 AI 4 11
4
[10] .init PROGBITS 00010380 000380 00000c 00 AX 0 0
4
[11] .plt PROGBITS 0001038c 00038c 000044 04 AX 0 0
4
[12] .text PROGBITS 000103d0 0003d0 0001f8 00 AX 0 0
4
[13] .fini PROGBITS 000105c8 0005c8 000008 00 AX 0 0
4
[14] .rodata PROGBITS 000105d0 0005d0 000008 00 A 0 0
4
[15] .ARM.exidx ARM_EXIDX 000105d8 0005d8 000018 00 AL 12 0
4
[16] .eh_frame PROGBITS 000105f0 0005f0 000004 00 A 0 0
4
[17] .init_array INIT_ARRAY 000205f4 0005f4 000004 00 WA 0 0
4
[18] .fini_array FINI_ARRAY 000205f8 0005f8 000004 00 WA 0 0
4
[19] .jcr PROGBITS 000205fc 0005fc 000004 00 WA 0 0
4
[20] .dynamic DYNAMIC 00020600 000600 000100 08 WA 5 0
4
[21] .got PROGBITS 00020700 000700 000020 04 WA 0 0
4
[22] .data PROGBITS 00020720 000720 000008 00 WA 0 0
4
[23] .bss NOBITS 00020728 000728 000004 00 WA 0 0
1
[24] .comment PROGBITS 00000000 000728 00001f 01 MS 0 0
1
[25] .ARM.attributes ARM_ATTRIBUTES 00000000 000747 000037 00 0 0
1
[26] .shstrtab STRTAB 00000000 00077e 0000f3 00 0 0
1
[27] .symtab SYMTAB 00000000 000874 000700 10 28 86
4
[28] .strtab STRTAB 00000000 000f74 00041e 00 0 0
1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
EXIDX 0x0005d8 0x000105d8 0x000105d8 0x00018 0x00018 R 0x4
PHDR 0x000034 0x00010034 0x00010034 0x00100 0x00100 R E 0x4
INTERP 0x000134 0x00010134 0x00010134 0x00013 0x00013 R 0x1
[Requesting program interpreter: /lib/ld-linux.so.3]
LOAD 0x000000 0x00010000 0x00010000 0x005f4 0x005f4 R E 0x10000
LOAD 0x0005f4 0x000205f4 0x000205f4 0x00134 0x00138 RW 0x10000
DYNAMIC 0x000600 0x00020600 0x00020600 0x00100 0x00100 RW 0x4
NOTE 0x000148 0x00010148 0x00010148 0x00020 0x00020 R 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10
Section to Segment mapping:
Segment Sections...
00 .ARM.exidx
01
02 .interp
03 .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version
.gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.exidx
.eh_frame
04 .init_array .fini_array .jcr .dynamic .got .data .bss
05 .dynamic
06 .note.ABI-tag
07
Dynamic section at offset 0x600 contains 27 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.6]
0x0000000c (INIT) 0x10380
0x0000000d (FINI) 0x105c8
0x00000019 (INIT_ARRAY) 0x205f4
0x0000001b (INIT_ARRAYSZ) 4 (bytes)
0x0000001a (FINI_ARRAY) 0x205f8
0x0000001c (FINI_ARRAYSZ) 4 (bytes)
0x00000004 (HASH) 0x10168
0x00000005 (STRTAB) 0x10230
0x00000006 (SYMTAB) 0x101a0
0x0000000a (STRSZ) 211 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000015 (DEBUG) 0x0
0x00000003 (PLTGOT) 0x20700
0x00000002 (PLTRELSZ) 32 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0x10360
0x00000011 (REL) 0x10358
0x00000012 (RELSZ) 8 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x6ffffffe (VERNEED) 0x10318
0x6fffffff (VERNEEDNUM) 2
0x6ffffff0 (VERSYM) 0x10304
0x00000000 (NULL) 0x0
Relocation section '.rel.dyn' at offset 0x358 contains 1 entries:
Offset Info Type Sym.Value Sym. Name
0002071c 00000415 R_ARM_GLOB_DAT 00000000 __gmon_start__
Relocation section '.rel.plt' at offset 0x360 contains 4 entries:
Offset Info Type Sym.Value Sym. Name
0002070c 00000116 R_ARM_JUMP_SLOT 00000000 abort
00020710 00000216 R_ARM_JUMP_SLOT 00000000 __libc_start_main
00020714 00000416 R_ARM_JUMP_SLOT 00000000 __gmon_start__
00020718 00000816 R_ARM_JUMP_SLOT 00000000 printf
Unwind table index '.ARM.exidx' at offset 0x5d8 contains 3 entries:
0x103d0 <_start>: 0x1 [cantunwind]
0x104f4 <main>: 0x80840db0
Compact model index: 0
0x84 0x0d pop {r4, r6, r7, r14}
0xb0 finish
0x10564 <__libc_csu_init>: 0x1 [cantunwind]
Symbol table '.dynsym' contains 9 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 FUNC GLOBAL DEFAULT UND abort@GLIBC_2.4 (2)
2: 00000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.4
(2)
3: 00000000 0 FUNC GLOBAL DEFAULT UND
__aeabi_unwind_cpp_pr0@GCC_3.5 (3)
4: 00000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
5: 00000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
6: 00000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
7: 00000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
8: 00000000 0 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.4 (2)
Symbol table '.symtab' contains 112 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00010134 0 SECTION LOCAL DEFAULT 1
2: 00010148 0 SECTION LOCAL DEFAULT 2
3: 00010168 0 SECTION LOCAL DEFAULT 3
4: 000101a0 0 SECTION LOCAL DEFAULT 4
5: 00010230 0 SECTION LOCAL DEFAULT 5
6: 00010304 0 SECTION LOCAL DEFAULT 6
7: 00010318 0 SECTION LOCAL DEFAULT 7
8: 00010358 0 SECTION LOCAL DEFAULT 8
9: 00010360 0 SECTION LOCAL DEFAULT 9
10: 00010380 0 SECTION LOCAL DEFAULT 10
11: 0001038c 0 SECTION LOCAL DEFAULT 11
12: 000103d0 0 SECTION LOCAL DEFAULT 12
13: 000105c8 0 SECTION LOCAL DEFAULT 13
14: 000105d0 0 SECTION LOCAL DEFAULT 14
15: 000105d8 0 SECTION LOCAL DEFAULT 15
16: 000105f0 0 SECTION LOCAL DEFAULT 16
17: 000205f4 0 SECTION LOCAL DEFAULT 17
18: 000205f8 0 SECTION LOCAL DEFAULT 18
19: 000205fc 0 SECTION LOCAL DEFAULT 19
20: 00020600 0 SECTION LOCAL DEFAULT 20
21: 00020700 0 SECTION LOCAL DEFAULT 21
22: 00020720 0 SECTION LOCAL DEFAULT 22
23: 00020728 0 SECTION LOCAL DEFAULT 23
24: 00000000 0 SECTION LOCAL DEFAULT 24
25: 00000000 0 SECTION LOCAL DEFAULT 25
26: 00000000 0 FILE LOCAL DEFAULT ABS /home/macieja/Documents/b
27: 00010148 0 NOTYPE LOCAL DEFAULT 2 $d
28: 00000000 0 FILE LOCAL DEFAULT ABS /home/macieja/Documents/b
29: 000103d0 0 NOTYPE LOCAL DEFAULT 12 $a
30: 000105d8 0 NOTYPE LOCAL DEFAULT 15 $d
31: 00010400 0 NOTYPE LOCAL DEFAULT 12 $d
32: 00000000 0 FILE LOCAL DEFAULT ABS init.c
33: 000105d0 0 NOTYPE LOCAL DEFAULT 14 $d
34: 00020720 0 NOTYPE LOCAL DEFAULT 22 $d
35: 00000000 0 FILE LOCAL DEFAULT ABS /usr/local/buildroot_cort
36: 0001040c 0 NOTYPE LOCAL DEFAULT 12 $a
37: 0001040c 0 FUNC LOCAL DEFAULT 12 call_weak_fn
38: 00010428 0 NOTYPE LOCAL DEFAULT 12 $d
39: 00010380 0 NOTYPE LOCAL DEFAULT 10 $a
40: 000105c8 0 NOTYPE LOCAL DEFAULT 13 $a
41: 00000000 0 FILE LOCAL DEFAULT ABS /usr/local/buildroot_cort
42: 00010388 0 NOTYPE LOCAL DEFAULT 10 $a
43: 000105cc 0 NOTYPE LOCAL DEFAULT 13 $a
44: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
45: 000205fc 0 OBJECT LOCAL DEFAULT 19 __JCR_LIST__
46: 00010430 0 NOTYPE LOCAL DEFAULT 12 $a
47: 00010430 0 FUNC LOCAL DEFAULT 12 deregister_tm_clones
48: 00010454 0 NOTYPE LOCAL DEFAULT 12 $d
49: 00010460 0 NOTYPE LOCAL DEFAULT 12 $a
50: 00010460 0 FUNC LOCAL DEFAULT 12 register_tm_clones
51: 0001048c 0 NOTYPE LOCAL DEFAULT 12 $d
52: 00020724 0 NOTYPE LOCAL DEFAULT 22 $d
53: 00010498 0 NOTYPE LOCAL DEFAULT 12 $a
54: 00010498 0 FUNC LOCAL DEFAULT 12 __do_global_dtors_aux
55: 000104bc 0 NOTYPE LOCAL DEFAULT 12 $d
56: 00020728 1 OBJECT LOCAL DEFAULT 23 completed.8966
57: 000205f8 0 NOTYPE LOCAL DEFAULT 18 $d
58: 000205f8 0 OBJECT LOCAL DEFAULT 18 __do_global_dtors_aux_fin
59: 000104c0 0 NOTYPE LOCAL DEFAULT 12 $a
60: 000104c0 0 FUNC LOCAL DEFAULT 12 frame_dummy
61: 000104ec 0 NOTYPE LOCAL DEFAULT 12 $d
62: 000205f4 0 NOTYPE LOCAL DEFAULT 17 $d
63: 000205f4 0 OBJECT LOCAL DEFAULT 17 __frame_dummy_init_array_
64: 00020728 0 NOTYPE LOCAL DEFAULT 23 $d
65: 00000000 0 FILE LOCAL DEFAULT ABS main.c
66: 000104f4 0 NOTYPE LOCAL DEFAULT 12 $a
67: 000105e0 0 NOTYPE LOCAL DEFAULT 15 $d
68: 000105d4 0 NOTYPE LOCAL DEFAULT 14 $d
69: 00000000 0 FILE LOCAL DEFAULT ABS elf-init.c
70: 00010564 0 NOTYPE LOCAL DEFAULT 12 $a
71: 000105bc 0 NOTYPE LOCAL DEFAULT 12 $d
72: 000105c4 0 NOTYPE LOCAL DEFAULT 12 $a
73: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
74: 000105f0 0 NOTYPE LOCAL DEFAULT 16 $d
75: 000105f0 0 OBJECT LOCAL DEFAULT 16 __FRAME_END__
76: 000205fc 0 NOTYPE LOCAL DEFAULT 19 $d
77: 000205fc 0 OBJECT LOCAL DEFAULT 19 __JCR_END__
78: 00000000 0 FILE LOCAL DEFAULT ABS
79: 00020700 0 OBJECT LOCAL DEFAULT 21 _GLOBAL_OFFSET_TABLE_
80: 000205f8 0 NOTYPE LOCAL DEFAULT 17 __init_array_end
81: 000205f4 0 NOTYPE LOCAL DEFAULT 17 __init_array_start
82: 00020600 0 OBJECT LOCAL DEFAULT 20 _DYNAMIC
83: 0001038c 0 NOTYPE LOCAL DEFAULT 11 $a
84: 0001039c 0 NOTYPE LOCAL DEFAULT 11 $d
85: 000103a0 0 NOTYPE LOCAL DEFAULT 11 $a
86: 00020720 0 NOTYPE WEAK DEFAULT 22 data_start
87: 00000000 0 FUNC GLOBAL DEFAULT UND abort@@GLIBC_2.4
88: 000105c4 4 FUNC GLOBAL DEFAULT 12 __libc_csu_fini
89: 000103d0 0 FUNC GLOBAL DEFAULT 12 _start
90: 00000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@@GLIBC_
91: 00000000 0 FUNC GLOBAL DEFAULT UND __aeabi_unwind_cpp_pr0@@G
92: 00000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
93: 00000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
94: 000105c8 0 FUNC GLOBAL DEFAULT 13 _fini
95: 00000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
96: 000105d0 4 OBJECT GLOBAL DEFAULT 14 _IO_stdin_used
97: 00000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
98: 00020720 0 NOTYPE GLOBAL DEFAULT 22 __data_start
99: 00020728 0 NOTYPE GLOBAL DEFAULT 23 __bss_start__
100: 00020728 0 OBJECT GLOBAL HIDDEN 22 __TMC_END__
101: 00020724 0 OBJECT GLOBAL HIDDEN 22 __dso_handle
102: 0002072c 0 NOTYPE GLOBAL DEFAULT 23 __end__
103: 00010564 96 FUNC GLOBAL DEFAULT 12 __libc_csu_init
104: 0002072c 0 NOTYPE GLOBAL DEFAULT 23 __bss_end__
105: 00000000 0 FUNC GLOBAL DEFAULT UND printf@@GLIBC_2.4
106: 00020728 0 NOTYPE GLOBAL DEFAULT 23 __bss_start
107: 0002072c 0 NOTYPE GLOBAL DEFAULT 23 _bss_end__
108: 0002072c 0 NOTYPE GLOBAL DEFAULT 23 _end
109: 00020728 0 NOTYPE GLOBAL DEFAULT 22 _edata
110: 000104f4 112 FUNC GLOBAL DEFAULT 12 main
111: 00010380 0 FUNC GLOBAL DEFAULT 10 _init
Histogram for bucket list length (total of 3 buckets):
Length Number % of total Coverage
0 0 ( 0.0%)
1 0 ( 0.0%) 0.0%
2 2 ( 66.7%) 50.0%
3 0 ( 0.0%) 50.0%
4 1 ( 33.3%) 100.0%
Version symbols section '.gnu.version' contains 9 entries:
Addr: 0000000000010304 Offset: 0x000304 Link: 4 (.dynsym)
000: 0 (*local*) 2 (GLIBC_2.4) 2 (GLIBC_2.4) 3 (GCC_3.5)
004: 0 (*local*) 0 (*local*) 0 (*local*) 0 (*local*)
008: 2 (GLIBC_2.4)
Version needs section '.gnu.version_r' contains 2 entries:
Addr: 0x0000000000010318 Offset: 0x000318 Link: 5 (.dynstr)
000000: Version: 1 File: libgcc_s.so.1 Cnt: 1
0x0010: Name: GCC_3.5 Flags: none Version: 3
0x0020: Version: 1 File: libc.so.6 Cnt: 1
0x0030: Name: GLIBC_2.4 Flags: none Version: 2
Displaying notes found at file offset 0x00000148 with length 0x00000020:
Owner Data size Description
GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag)
OS: Linux, ABI: 2.6.32
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "Cortex-A8"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_rounding: Needed
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_CPU_unaligned_access: v6
Tag_Virtualization_use: TrustZone
-- READELF --
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/66239] Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp]
2015-05-21 10:56 [Bug c++/66239] New: Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp] maciej.andrzejewski at data dot pl
@ 2015-05-21 15:28 ` ramana at gcc dot gnu.org
2015-05-21 16:53 ` ktkachov at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ramana at gcc dot gnu.org @ 2015-05-21 15:28 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 53427 bytes --]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66239
Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ramana at gcc dot gnu.org
--- Comment #2 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> ---
(In reply to Maciej Andrzejewski from comment #1)
> It is getting even more interesting.
>
> I have disassabled 4 binaries compiled with options:
> 1) -mfloat-abi=softfp
> 2) -mfloat-abi=softfp -O
> 3) -mfloat-abi=hard
> 4) -mfloat-abi=hard -O
>
> and from what I understand if we turn ON the optimization the FPU is turned
> OFF!
> I dont see in assembler that FPU s** registers are used in those two cases
> where optimization is turned on:
Yeah it's called constant folding in the compiler. Why make the cpu do more
work at run time when the compiler can statically tell you the value for sqrt
of a floating point value. The cycles spent in compiling with -O have to give
you some value surely ... :)
I have no idea why your -O0 case fails though, offhand.
Ramana
>
> -- DISASSAMBLE OPTION 1 --
> 00010570 <main>:
> 10570: e92d4800 push {fp, lr}
> 10574: e28db004 add fp, sp, #4
> 10578: e24dd040 sub sp, sp, #64 ; 0x40
> 1057c: e3032333 movw r2, #13107 ; 0x3333
> 10580: e3432333 movt r2, #13107 ; 0x3333
> 10584: e3033333 movw r3, #13107 ; 0x3333
> 10588: e3443022 movt r3, #16418 ; 0x4022
> 1058c: e14b20fc strd r2, [fp, #-12]
> 10590: ed5b0b03 vldr d16, [fp, #-12]
> 10594: eef77be0 vcvt.f32.f64 s15, d16
> 10598: ee170a90 vmov r0, s15
> 1059c: ebffffa1 bl 10428 <sqrtf@plt>
> 105a0: ee070a90 vmov s15, r0
> 105a4: eef70ae7 vcvt.f64.f32 d16, s15
> 105a8: ed4b0b05 vstr d16, [fp, #-20] ; 0xffffffec
> 105ac: e30006cc movw r0, #1740 ; 0x6cc
> 105b0: e3400001 movt r0, #1
> 105b4: e14b21d4 ldrd r2, [fp, #-20] ; 0xffffffec
> 105b8: ebffffa0 bl 10440 <printf@plt>
> 105bc: e309399a movw r3, #39322 ; 0x999a
> 105c0: e3443111 movt r3, #16657 ; 0x4111
> 105c4: e50b3018 str r3, [fp, #-24] ; 0xffffffe8
> 105c8: e51b0018 ldr r0, [fp, #-24] ; 0xffffffe8
> 105cc: ebffff95 bl 10428 <sqrtf@plt>
> 105d0: ee070a90 vmov s15, r0
> 105d4: eef70ae7 vcvt.f64.f32 d16, s15
> 105d8: ed4b0b09 vstr d16, [fp, #-36] ; 0xffffffdc
> 105dc: e30006cc movw r0, #1740 ; 0x6cc
> 105e0: e3400001 movt r0, #1
> 105e4: e14b22d4 ldrd r2, [fp, #-36] ; 0xffffffdc
> 105e8: ebffff94 bl 10440 <printf@plt>
> 105ec: e3032333 movw r2, #13107 ; 0x3333
> 105f0: e3432333 movt r2, #13107 ; 0x3333
> 105f4: e3033333 movw r3, #13107 ; 0x3333
> 105f8: e3443022 movt r3, #16418 ; 0x4022
> 105fc: e14b22fc strd r2, [fp, #-44] ; 0xffffffd4
> 10600: e14b02dc ldrd r0, [fp, #-44] ; 0xffffffd4
> 10604: ebffff8a bl 10434 <sqrt@plt>
> 10608: e14b03f4 strd r0, [fp, #-52] ; 0xffffffcc
> 1060c: e30006cc movw r0, #1740 ; 0x6cc
> 10610: e3400001 movt r0, #1
> 10614: e14b23d4 ldrd r2, [fp, #-52] ; 0xffffffcc
> 10618: ebffff88 bl 10440 <printf@plt>
> 1061c: e309399a movw r3, #39322 ; 0x999a
> 10620: e3443111 movt r3, #16657 ; 0x4111
> 10624: e50b3038 str r3, [fp, #-56] ; 0xffffffc8
> 10628: ed5b7a0e vldr s15, [fp, #-56] ; 0xffffffc8
> 1062c: eef70ae7 vcvt.f64.f32 d16, s15
> 10630: ec510b30 vmov r0, r1, d16
> 10634: ebffff7e bl 10434 <sqrt@plt>
> 10638: e14b04f4 strd r0, [fp, #-68] ; 0xffffffbc
> 1063c: e30006cc movw r0, #1740 ; 0x6cc
> 10640: e3400001 movt r0, #1
> 10644: e14b24d4 ldrd r2, [fp, #-68] ; 0xffffffbc
> 10648: ebffff7c bl 10440 <printf@plt>
> 1064c: e3a03000 mov r3, #0
> 10650: e1a00003 mov r0, r3
> 10654: e24bd004 sub sp, fp, #4
> 10658: e8bd8800 pop {fp, pc}
> -- DISASSAMBLE OPTION 1 --
>
>
>
> -- DISASSAMBLE OPTION 2 --
> 000104f4 <main>:
> 104f4: e92d40d0 push {r4, r6, r7, lr}
> 104f8: e30045d4 movw r4, #1492 ; 0x5d4
> 104fc: e3404001 movt r4, #1
> 10500: e3a06000 mov r6, #0
> 10504: e302720a movw r7, #8714 ; 0x220a
> 10508: e3447008 movt r7, #16392 ; 0x4008
> 1050c: e1a00004 mov r0, r4
> 10510: e1a02006 mov r2, r6
> 10514: e1a03007 mov r3, r7
> 10518: ebffffa9 bl 103c4 <printf@plt>
> 1051c: e1a00004 mov r0, r4
> 10520: e1a02006 mov r2, r6
> 10524: e1a03007 mov r3, r7
> 10528: ebffffa5 bl 103c4 <printf@plt>
> 1052c: e1a00004 mov r0, r4
> 10530: e30f2d38 movw r2, #64824 ; 0xfd38
> 10534: e34f2ea1 movt r2, #65185 ; 0xfea1
> 10538: e3023209 movw r3, #8713 ; 0x2209
> 1053c: e3443008 movt r3, #16392 ; 0x4008
> 10540: ebffff9f bl 103c4 <printf@plt>
> 10544: e1a00004 mov r0, r4
> 10548: e3072c82 movw r2, #31874 ; 0x7c82
> 1054c: e340271e movt r2, #1822 ; 0x71e
> 10550: e302320a movw r3, #8714 ; 0x220a
> 10554: e3443008 movt r3, #16392 ; 0x4008
> 10558: ebffff99 bl 103c4 <printf@plt>
> 1055c: e3a00000 mov r0, #0
> 10560: e8bd80d0 pop {r4, r6, r7, pc}
> -- DISASSAMBLE OPTION 2 --
>
>
>
> -- DISASSAMBLE OPTION 3 --
> 00008578 <main>:
> 8578: e92d4800 push {fp, lr}
> 857c: e28db004 add fp, sp, #4
> 8580: e24dd040 sub sp, sp, #64 ; 0x40
> 8584: e3032333 movw r2, #13107 ; 0x3333
> 8588: e3432333 movt r2, #13107 ; 0x3333
> 858c: e3033333 movw r3, #13107 ; 0x3333
> 8590: e3443022 movt r3, #16418 ; 0x4022
> 8594: e14b20fc strd r2, [fp, #-12]
> 8598: ed5b0b03 vldr d16, [fp, #-12]
> 859c: eef77be0 vcvt.f32.f64 s15, d16
> 85a0: eeb00a67 vmov.f32 s0, s15
> 85a4: ebffffa1 bl 8430 <_init+0x44>
> 85a8: eef07a40 vmov.f32 s15, s0
> 85ac: eef70ae7 vcvt.f64.f32 d16, s15
> 85b0: ed4b0b05 vstr d16, [fp, #-20] ; 0xffffffec
> 85b4: e30806d4 movw r0, #34516 ; 0x86d4
> 85b8: e3400000 movt r0, #0
> 85bc: e14b21d4 ldrd r2, [fp, #-20] ; 0xffffffec
> 85c0: ebffffa0 bl 8448 <_init+0x5c>
> 85c4: e309399a movw r3, #39322 ; 0x999a
> 85c8: e3443111 movt r3, #16657 ; 0x4111
> 85cc: e50b3018 str r3, [fp, #-24]
> 85d0: ed1b0a06 vldr s0, [fp, #-24] ; 0xffffffe8
> 85d4: ebffff95 bl 8430 <_init+0x44>
> 85d8: eef07a40 vmov.f32 s15, s0
> 85dc: eef70ae7 vcvt.f64.f32 d16, s15
> 85e0: ed4b0b09 vstr d16, [fp, #-36] ; 0xffffffdc
> 85e4: e30806d4 movw r0, #34516 ; 0x86d4
> 85e8: e3400000 movt r0, #0
> 85ec: e14b22d4 ldrd r2, [fp, #-36] ; 0xffffffdc
> 85f0: ebffff94 bl 8448 <_init+0x5c>
> 85f4: e3032333 movw r2, #13107 ; 0x3333
> 85f8: e3432333 movt r2, #13107 ; 0x3333
> 85fc: e3033333 movw r3, #13107 ; 0x3333
> 8600: e3443022 movt r3, #16418 ; 0x4022
> 8604: e14b22fc strd r2, [fp, #-44] ; 0xffffffd4
> 8608: ed1b0b0b vldr d0, [fp, #-44] ; 0xffffffd4
> 860c: ebffff8a bl 843c <_init+0x50>
> 8610: ed0b0b0d vstr d0, [fp, #-52] ; 0xffffffcc
> 8614: e30806d4 movw r0, #34516 ; 0x86d4
> 8618: e3400000 movt r0, #0
> 861c: e14b23d4 ldrd r2, [fp, #-52] ; 0xffffffcc
> 8620: ebffff88 bl 8448 <_init+0x5c>
> 8624: e309399a movw r3, #39322 ; 0x999a
> 8628: e3443111 movt r3, #16657 ; 0x4111
> 862c: e50b3038 str r3, [fp, #-56] ; 0x38
> 8630: ed5b7a0e vldr s15, [fp, #-56] ; 0xffffffc8
> 8634: eef70ae7 vcvt.f64.f32 d16, s15
> 8638: eeb00b60 vmov.f64 d0, d16
> 863c: ebffff7e bl 843c <_init+0x50>
> 8640: ed0b0b11 vstr d0, [fp, #-68] ; 0xffffffbc
> 8644: e30806d4 movw r0, #34516 ; 0x86d4
> 8648: e3400000 movt r0, #0
> 864c: e14b24d4 ldrd r2, [fp, #-68] ; 0xffffffbc
> 8650: ebffff7c bl 8448 <_init+0x5c>
> 8654: e3a03000 mov r3, #0
> 8658: e1a00003 mov r0, r3
> 865c: e24bd004 sub sp, fp, #4
> 8660: e8bd8800 pop {fp, pc}
>
> -- DISASSAMBLE OPTION 3 --
>
>
>
> -- DISASSAMBLE OPTION 4 --
> 000084fc <main>:
> 84fc: e92d40d0 push {r4, r6, r7, lr}
> 8500: e30845dc movw r4, #34268 ; 0x85dc
> 8504: e3404000 movt r4, #0
> 8508: e3a06000 mov r6, #0
> 850c: e302720a movw r7, #8714 ; 0x220a
> 8510: e3447008 movt r7, #16392 ; 0x4008
> 8514: e1a00004 mov r0, r4
> 8518: e1a02006 mov r2, r6
> 851c: e1a03007 mov r3, r7
> 8520: ebffffa9 bl 83cc <_init+0x44>
> 8524: e1a00004 mov r0, r4
> 8528: e1a02006 mov r2, r6
> 852c: e1a03007 mov r3, r7
> 8530: ebffffa5 bl 83cc <_init+0x44>
> 8534: e1a00004 mov r0, r4
> 8538: e30f2d38 movw r2, #64824 ; 0xfd38
> 853c: e34f2ea1 movt r2, #65185 ; 0xfea1
> 8540: e3023209 movw r3, #8713 ; 0x2209
> 8544: e3443008 movt r3, #16392 ; 0x4008
> 8548: ebffff9f bl 83cc <_init+0x44>
> 854c: e1a00004 mov r0, r4
> 8550: e3072c82 movw r2, #31874 ; 0x7c82
> 8554: e340271e movt r2, #1822 ; 0x71e
> 8558: e302320a movw r3, #8714 ; 0x220a
> 855c: e3443008 movt r3, #16392 ; 0x4008
> 8560: ebffff99 bl 83cc <_init+0x44>
> 8564: e3a00000 mov r0, #0
> 8568: e8bd80d0 pop {r4, r6, r7, pc}
> -- DISASSAMBLE OPTION 4 --
>
> (In reply to Maciej Andrzejewski from comment #0)
> > Tested both on GCC 4.9.1 (compiled toolchain using crosstool-ng) and 4.9.2
> > (compiled toolchain using buildroot).
> >
> > Simple code:
> >
> > -- CODE --
> > #include <stdio.h>
> > #include <cmath>
> > #include <math.h>
> >
> >
> > int main( void )
> > {
> > double sq3 = 9.1;
> > double ret3 = sqrtf(sq3);
> > printf("%f\n", ret3);
> >
> > float sq4 = 9.1;
> > double ret4 = sqrtf(sq4);
> > printf("%f\n", ret4);
> >
> > double sq1 = 9.1;
> > double ret1 = sqrt(sq1);
> > printf("%f\n", ret1);
> >
> > float sq2 = 9.1;
> > double ret2 = sqrt(sq2);
> > printf("%f\n", ret2);
> >
> > return 0;
> > }
> > -- CODE --
> >
> > compiled with command:
> > g++ -mcpu=cortex-a8 -march=armv7-a -mtune=cortex-a8 -mfpu=neon
> > -mthumb-interwork -mfpu=neon -Wall -Wextra -mfloat-abi=softfp
> >
> > or
> >
> > g++ -mcpu=cortex-a8 -march=armv7-a -mtune=cortex-a8 -mfpu=neon
> > -mthumb-interwork -mfpu=neon -Wall -Wextra -mfloat-abi=soft
> >
> > prints output when run:
> > -- OUTPUT --
> > 0.000000
> > 0.000000
> > 89884613882771507935772421602449274280826426490922860415370742828850803088708
> > 43656890933893326861538272573183614877997670352187692139688355386197138142676
> > 33945847309741616433412271681163246268102419739642257742722331754068434663711
> > 41886318608237834273423597057507238373804952327520531541920130815989439791104
> > .000000
> > 89884613882771507935772421602449274280826426490922860415370742828850803088708
> > 43656890933893326861538272573183614877997670352187692139688355386197138142676
> > 33945847309741616433412271681163246268102419739642257742722331754068434663711
> > 41886318608237834273423597057507238373804952327520531541920130815989439791104
> > .000000
> > -- OUTPUT --
> >
> > when compiled with added ANY optimization flag (O, O1, O2, O3, Og) prints
> > proper output:
> > -- OUTPUT 2 --
> > 3.016621
> > 3.016621
> > 3.016621
> > 3.016621
> > -- OUTPUT 2 --
> >
> >
> >
> >
> > *** Additional info ***
> >
> > g++ --version:
> > arm-none-linux-gnueabi-g++ (Buildroot 2015.02) 4.9.2
> >
> > readelf -a a.out:
> > -- READELF --
> > macieja@ubuntu:~/Projects/sqrtf$ readelf -a a.out
> > ELF Header:
> > Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
> > Class: ELF32
> > Data: 2's complement, little endian
> > Version: 1 (current)
> > OS/ABI: UNIX - System V
> > ABI Version: 0
> > Type: EXEC (Executable file)
> > Machine: ARM
> > Version: 0x1
> > Entry point address: 0x103d0
> > Start of program headers: 52 (bytes into file)
> > Start of section headers: 5012 (bytes into file)
> > Flags: 0x5000202, has entry point, Version5
> > EABI, soft-float ABI
> > Size of this header: 52 (bytes)
> > Size of program headers: 32 (bytes)
> > Number of program headers: 8
> > Size of section headers: 40 (bytes)
> > Number of section headers: 29
> > Section header string table index: 26
> >
> > Section Headers:
> > [Nr] Name Type Addr Off Size ES Flg Lk
> > Inf Al
> > [ 0] NULL 00000000 000000 000000 00 0
> > 0 0
> > [ 1] .interp PROGBITS 00010134 000134 000013 00 A 0
> > 0 1
> > [ 2] .note.ABI-tag NOTE 00010148 000148 000020 00 A 0
> > 0 4
> > [ 3] .hash HASH 00010168 000168 000038 04 A 4
> > 0 4
> > [ 4] .dynsym DYNSYM 000101a0 0001a0 000090 10 A 5
> > 1 4
> > [ 5] .dynstr STRTAB 00010230 000230 0000d3 00 A 0
> > 0 1
> > [ 6] .gnu.version VERSYM 00010304 000304 000012 02 A 4
> > 0 2
> > [ 7] .gnu.version_r VERNEED 00010318 000318 000040 00 A 5
> > 2 4
> > [ 8] .rel.dyn REL 00010358 000358 000008 08 A 4
> > 0 4
> > [ 9] .rel.plt REL 00010360 000360 000020 08 AI 4
> > 11 4
> > [10] .init PROGBITS 00010380 000380 00000c 00 AX 0
> > 0 4
> > [11] .plt PROGBITS 0001038c 00038c 000044 04 AX 0
> > 0 4
> > [12] .text PROGBITS 000103d0 0003d0 0001f8 00 AX 0
> > 0 4
> > [13] .fini PROGBITS 000105c8 0005c8 000008 00 AX 0
> > 0 4
> > [14] .rodata PROGBITS 000105d0 0005d0 000008 00 A 0
> > 0 4
> > [15] .ARM.exidx ARM_EXIDX 000105d8 0005d8 000018 00 AL 12
> > 0 4
> > [16] .eh_frame PROGBITS 000105f0 0005f0 000004 00 A 0
> > 0 4
> > [17] .init_array INIT_ARRAY 000205f4 0005f4 000004 00 WA 0
> > 0 4
> > [18] .fini_array FINI_ARRAY 000205f8 0005f8 000004 00 WA 0
> > 0 4
> > [19] .jcr PROGBITS 000205fc 0005fc 000004 00 WA 0
> > 0 4
> > [20] .dynamic DYNAMIC 00020600 000600 000100 08 WA 5
> > 0 4
> > [21] .got PROGBITS 00020700 000700 000020 04 WA 0
> > 0 4
> > [22] .data PROGBITS 00020720 000720 000008 00 WA 0
> > 0 4
> > [23] .bss NOBITS 00020728 000728 000004 00 WA 0
> > 0 1
> > [24] .comment PROGBITS 00000000 000728 00001f 01 MS 0
> > 0 1
> > [25] .ARM.attributes ARM_ATTRIBUTES 00000000 000747 000037 00 0
> > 0 1
> > [26] .shstrtab STRTAB 00000000 00077e 0000f3 00 0
> > 0 1
> > [27] .symtab SYMTAB 00000000 000874 000700 10 28
> > 86 4
> > [28] .strtab STRTAB 00000000 000f74 00041e 00 0
> > 0 1
> > Key to Flags:
> > W (write), A (alloc), X (execute), M (merge), S (strings)
> > I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
> > O (extra OS processing required) o (OS specific), p (processor specific)
> >
> > There are no section groups in this file.
> >
> > Program Headers:
> > Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> > EXIDX 0x0005d8 0x000105d8 0x000105d8 0x00018 0x00018 R 0x4
> > PHDR 0x000034 0x00010034 0x00010034 0x00100 0x00100 R E 0x4
> > INTERP 0x000134 0x00010134 0x00010134 0x00013 0x00013 R 0x1
> > [Requesting program interpreter: /lib/ld-linux.so.3]
> > LOAD 0x000000 0x00010000 0x00010000 0x005f4 0x005f4 R E 0x10000
> > LOAD 0x0005f4 0x000205f4 0x000205f4 0x00134 0x00138 RW 0x10000
> > DYNAMIC 0x000600 0x00020600 0x00020600 0x00100 0x00100 RW 0x4
> > NOTE 0x000148 0x00010148 0x00010148 0x00020 0x00020 R 0x4
> > GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10
> >
> > Section to Segment mapping:
> > Segment Sections...
> > 00 .ARM.exidx
> > 01
> > 02 .interp
> > 03 .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version
> > .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.exidx
> > .eh_frame
> > 04 .init_array .fini_array .jcr .dynamic .got .data .bss
> > 05 .dynamic
> > 06 .note.ABI-tag
> > 07
> >
> > Dynamic section at offset 0x600 contains 27 entries:
> > Tag Type Name/Value
> > 0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
> > 0x00000001 (NEEDED) Shared library: [libm.so.6]
> > 0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
> > 0x00000001 (NEEDED) Shared library: [libc.so.6]
> > 0x0000000c (INIT) 0x10380
> > 0x0000000d (FINI) 0x105c8
> > 0x00000019 (INIT_ARRAY) 0x205f4
> > 0x0000001b (INIT_ARRAYSZ) 4 (bytes)
> > 0x0000001a (FINI_ARRAY) 0x205f8
> > 0x0000001c (FINI_ARRAYSZ) 4 (bytes)
> > 0x00000004 (HASH) 0x10168
> > 0x00000005 (STRTAB) 0x10230
> > 0x00000006 (SYMTAB) 0x101a0
> > 0x0000000a (STRSZ) 211 (bytes)
> > 0x0000000b (SYMENT) 16 (bytes)
> > 0x00000015 (DEBUG) 0x0
> > 0x00000003 (PLTGOT) 0x20700
> > 0x00000002 (PLTRELSZ) 32 (bytes)
> > 0x00000014 (PLTREL) REL
> > 0x00000017 (JMPREL) 0x10360
> > 0x00000011 (REL) 0x10358
> > 0x00000012 (RELSZ) 8 (bytes)
> > 0x00000013 (RELENT) 8 (bytes)
> > 0x6ffffffe (VERNEED) 0x10318
> > 0x6fffffff (VERNEEDNUM) 2
> > 0x6ffffff0 (VERSYM) 0x10304
> > 0x00000000 (NULL) 0x0
> >
> > Relocation section '.rel.dyn' at offset 0x358 contains 1 entries:
> > Offset Info Type Sym.Value Sym. Name
> > 0002071c 00000415 R_ARM_GLOB_DAT 00000000 __gmon_start__
> >
> > Relocation section '.rel.plt' at offset 0x360 contains 4 entries:
> > Offset Info Type Sym.Value Sym. Name
> > 0002070c 00000116 R_ARM_JUMP_SLOT 00000000 abort
> > 00020710 00000216 R_ARM_JUMP_SLOT 00000000 __libc_start_main
> > 00020714 00000416 R_ARM_JUMP_SLOT 00000000 __gmon_start__
> > 00020718 00000816 R_ARM_JUMP_SLOT 00000000 printf
> >
> > Unwind table index '.ARM.exidx' at offset 0x5d8 contains 3 entries:
> >
> > 0x103d0 <_start>: 0x1 [cantunwind]
> >
> > 0x104f4 <main>: 0x80840db0
> > Compact model index: 0
> > 0x84 0x0d pop {r4, r6, r7, r14}
> > 0xb0 finish
> >
> > 0x10564 <__libc_csu_init>: 0x1 [cantunwind]
> >
> >
> > Symbol table '.dynsym' contains 9 entries:
> > Num: Value Size Type Bind Vis Ndx Name
> > 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
> > 1: 00000000 0 FUNC GLOBAL DEFAULT UND abort@GLIBC_2.4 (2)
> > 2: 00000000 0 FUNC GLOBAL DEFAULT UND
> > __libc_start_main@GLIBC_2.4 (2)
> > 3: 00000000 0 FUNC GLOBAL DEFAULT UND
> > __aeabi_unwind_cpp_pr0@GCC_3.5 (3)
> > 4: 00000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
> > 5: 00000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
> > 6: 00000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
> > 7: 00000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
> > 8: 00000000 0 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.4 (2)
> >
> > Symbol table '.symtab' contains 112 entries:
> > Num: Value Size Type Bind Vis Ndx Name
> > 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
> > 1: 00010134 0 SECTION LOCAL DEFAULT 1
> > 2: 00010148 0 SECTION LOCAL DEFAULT 2
> > 3: 00010168 0 SECTION LOCAL DEFAULT 3
> > 4: 000101a0 0 SECTION LOCAL DEFAULT 4
> > 5: 00010230 0 SECTION LOCAL DEFAULT 5
> > 6: 00010304 0 SECTION LOCAL DEFAULT 6
> > 7: 00010318 0 SECTION LOCAL DEFAULT 7
> > 8: 00010358 0 SECTION LOCAL DEFAULT 8
> > 9: 00010360 0 SECTION LOCAL DEFAULT 9
> > 10: 00010380 0 SECTION LOCAL DEFAULT 10
> > 11: 0001038c 0 SECTION LOCAL DEFAULT 11
> > 12: 000103d0 0 SECTION LOCAL DEFAULT 12
> > 13: 000105c8 0 SECTION LOCAL DEFAULT 13
> > 14: 000105d0 0 SECTION LOCAL DEFAULT 14
> > 15: 000105d8 0 SECTION LOCAL DEFAULT 15
> > 16: 000105f0 0 SECTION LOCAL DEFAULT 16
> > 17: 000205f4 0 SECTION LOCAL DEFAULT 17
> > 18: 000205f8 0 SECTION LOCAL DEFAULT 18
> > 19: 000205fc 0 SECTION LOCAL DEFAULT 19
> > 20: 00020600 0 SECTION LOCAL DEFAULT 20
> > 21: 00020700 0 SECTION LOCAL DEFAULT 21
> > 22: 00020720 0 SECTION LOCAL DEFAULT 22
> > 23: 00020728 0 SECTION LOCAL DEFAULT 23
> > 24: 00000000 0 SECTION LOCAL DEFAULT 24
> > 25: 00000000 0 SECTION LOCAL DEFAULT 25
> > 26: 00000000 0 FILE LOCAL DEFAULT ABS /home/macieja/Documents/b
> > 27: 00010148 0 NOTYPE LOCAL DEFAULT 2 $d
> > 28: 00000000 0 FILE LOCAL DEFAULT ABS /home/macieja/Documents/b
> > 29: 000103d0 0 NOTYPE LOCAL DEFAULT 12 $a
> > 30: 000105d8 0 NOTYPE LOCAL DEFAULT 15 $d
> > 31: 00010400 0 NOTYPE LOCAL DEFAULT 12 $d
> > 32: 00000000 0 FILE LOCAL DEFAULT ABS init.c
> > 33: 000105d0 0 NOTYPE LOCAL DEFAULT 14 $d
> > 34: 00020720 0 NOTYPE LOCAL DEFAULT 22 $d
> > 35: 00000000 0 FILE LOCAL DEFAULT ABS /usr/local/buildroot_cort
> > 36: 0001040c 0 NOTYPE LOCAL DEFAULT 12 $a
> > 37: 0001040c 0 FUNC LOCAL DEFAULT 12 call_weak_fn
> > 38: 00010428 0 NOTYPE LOCAL DEFAULT 12 $d
> > 39: 00010380 0 NOTYPE LOCAL DEFAULT 10 $a
> > 40: 000105c8 0 NOTYPE LOCAL DEFAULT 13 $a
> > 41: 00000000 0 FILE LOCAL DEFAULT ABS /usr/local/buildroot_cort
> > 42: 00010388 0 NOTYPE LOCAL DEFAULT 10 $a
> > 43: 000105cc 0 NOTYPE LOCAL DEFAULT 13 $a
> > 44: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
> > 45: 000205fc 0 OBJECT LOCAL DEFAULT 19 __JCR_LIST__
> > 46: 00010430 0 NOTYPE LOCAL DEFAULT 12 $a
> > 47: 00010430 0 FUNC LOCAL DEFAULT 12 deregister_tm_clones
> > 48: 00010454 0 NOTYPE LOCAL DEFAULT 12 $d
> > 49: 00010460 0 NOTYPE LOCAL DEFAULT 12 $a
> > 50: 00010460 0 FUNC LOCAL DEFAULT 12 register_tm_clones
> > 51: 0001048c 0 NOTYPE LOCAL DEFAULT 12 $d
> > 52: 00020724 0 NOTYPE LOCAL DEFAULT 22 $d
> > 53: 00010498 0 NOTYPE LOCAL DEFAULT 12 $a
> > 54: 00010498 0 FUNC LOCAL DEFAULT 12 __do_global_dtors_aux
> > 55: 000104bc 0 NOTYPE LOCAL DEFAULT 12 $d
> > 56: 00020728 1 OBJECT LOCAL DEFAULT 23 completed.8966
> > 57: 000205f8 0 NOTYPE LOCAL DEFAULT 18 $d
> > 58: 000205f8 0 OBJECT LOCAL DEFAULT 18 __do_global_dtors_aux_fin
> > 59: 000104c0 0 NOTYPE LOCAL DEFAULT 12 $a
> > 60: 000104c0 0 FUNC LOCAL DEFAULT 12 frame_dummy
> > 61: 000104ec 0 NOTYPE LOCAL DEFAULT 12 $d
> > 62: 000205f4 0 NOTYPE LOCAL DEFAULT 17 $d
> > 63: 000205f4 0 OBJECT LOCAL DEFAULT 17 __frame_dummy_init_array_
> > 64: 00020728 0 NOTYPE LOCAL DEFAULT 23 $d
> > 65: 00000000 0 FILE LOCAL DEFAULT ABS main.c
> > 66: 000104f4 0 NOTYPE LOCAL DEFAULT 12 $a
> > 67: 000105e0 0 NOTYPE LOCAL DEFAULT 15 $d
> > 68: 000105d4 0 NOTYPE LOCAL DEFAULT 14 $d
> > 69: 00000000 0 FILE LOCAL DEFAULT ABS elf-init.c
> > 70: 00010564 0 NOTYPE LOCAL DEFAULT 12 $a
> > 71: 000105bc 0 NOTYPE LOCAL DEFAULT 12 $d
> > 72: 000105c4 0 NOTYPE LOCAL DEFAULT 12 $a
> > 73: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
> > 74: 000105f0 0 NOTYPE LOCAL DEFAULT 16 $d
> > 75: 000105f0 0 OBJECT LOCAL DEFAULT 16 __FRAME_END__
> > 76: 000205fc 0 NOTYPE LOCAL DEFAULT 19 $d
> > 77: 000205fc 0 OBJECT LOCAL DEFAULT 19 __JCR_END__
> > 78: 00000000 0 FILE LOCAL DEFAULT ABS
> > 79: 00020700 0 OBJECT LOCAL DEFAULT 21 _GLOBAL_OFFSET_TABLE_
> > 80: 000205f8 0 NOTYPE LOCAL DEFAULT 17 __init_array_end
> > 81: 000205f4 0 NOTYPE LOCAL DEFAULT 17 __init_array_start
> > 82: 00020600 0 OBJECT LOCAL DEFAULT 20 _DYNAMIC
> > 83: 0001038c 0 NOTYPE LOCAL DEFAULT 11 $a
> > 84: 0001039c 0 NOTYPE LOCAL DEFAULT 11 $d
> > 85: 000103a0 0 NOTYPE LOCAL DEFAULT 11 $a
> > 86: 00020720 0 NOTYPE WEAK DEFAULT 22 data_start
> > 87: 00000000 0 FUNC GLOBAL DEFAULT UND abort@@GLIBC_2.4
> > 88: 000105c4 4 FUNC GLOBAL DEFAULT 12 __libc_csu_fini
> > 89: 000103d0 0 FUNC GLOBAL DEFAULT 12 _start
> > 90: 00000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@@GLIBC_
> > 91: 00000000 0 FUNC GLOBAL DEFAULT UND __aeabi_unwind_cpp_pr0@@G
> > 92: 00000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
> > 93: 00000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
> > 94: 000105c8 0 FUNC GLOBAL DEFAULT 13 _fini
> > 95: 00000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
> > 96: 000105d0 4 OBJECT GLOBAL DEFAULT 14 _IO_stdin_used
> > 97: 00000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
> > 98: 00020720 0 NOTYPE GLOBAL DEFAULT 22 __data_start
> > 99: 00020728 0 NOTYPE GLOBAL DEFAULT 23 __bss_start__
> > 100: 00020728 0 OBJECT GLOBAL HIDDEN 22 __TMC_END__
> > 101: 00020724 0 OBJECT GLOBAL HIDDEN 22 __dso_handle
> > 102: 0002072c 0 NOTYPE GLOBAL DEFAULT 23 __end__
> > 103: 00010564 96 FUNC GLOBAL DEFAULT 12 __libc_csu_init
> > 104: 0002072c 0 NOTYPE GLOBAL DEFAULT 23 __bss_end__
> > 105: 00000000 0 FUNC GLOBAL DEFAULT UND printf@@GLIBC_2.4
> > 106: 00020728 0 NOTYPE GLOBAL DEFAULT 23 __bss_start
> > 107: 0002072c 0 NOTYPE GLOBAL DEFAULT 23 _bss_end__
> > 108: 0002072c 0 NOTYPE GLOBAL DEFAULT 23 _end
> > 109: 00020728 0 NOTYPE GLOBAL DEFAULT 22 _edata
> > 110: 000104f4 112 FUNC GLOBAL DEFAULT 12 main
> > 111: 00010380 0 FUNC GLOBAL DEFAULT 10 _init
> >
> > Histogram for bucket list length (total of 3 buckets):
> > Length Number % of total Coverage
> > 0 0 ( 0.0%)
> > 1 0 ( 0.0%) 0.0%
> > 2 2 ( 66.7%) 50.0%
> > 3 0 ( 0.0%) 50.0%
> > 4 1 ( 33.3%) 100.0%
> >
> > Version symbols section '.gnu.version' contains 9 entries:
> > Addr: 0000000000010304 Offset: 0x000304 Link: 4 (.dynsym)
> > 000: 0 (*local*) 2 (GLIBC_2.4) 2 (GLIBC_2.4) 3 (GCC_3.5)
> >
> > 004: 0 (*local*) 0 (*local*) 0 (*local*) 0 (*local*)
> >
> > 008: 2 (GLIBC_2.4)
> >
> > Version needs section '.gnu.version_r' contains 2 entries:
> > Addr: 0x0000000000010318 Offset: 0x000318 Link: 5 (.dynstr)
> > 000000: Version: 1 File: libgcc_s.so.1 Cnt: 1
> > 0x0010: Name: GCC_3.5 Flags: none Version: 3
> > 0x0020: Version: 1 File: libc.so.6 Cnt: 1
> > 0x0030: Name: GLIBC_2.4 Flags: none Version: 2
> >
> > Displaying notes found at file offset 0x00000148 with length 0x00000020:
> > Owner Data size Description
> > GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag)
> > OS: Linux, ABI: 2.6.32
> > Attribute Section: aeabi
> > File Attributes
> > Tag_CPU_name: "Cortex-A8"
> > Tag_CPU_arch: v7
> > Tag_CPU_arch_profile: Application
> > Tag_ARM_ISA_use: Yes
> > Tag_THUMB_ISA_use: Thumb-2
> > Tag_ABI_PCS_wchar_t: 4
> > Tag_ABI_FP_rounding: Needed
> > Tag_ABI_FP_denormal: Needed
> > Tag_ABI_FP_exceptions: Needed
> > Tag_ABI_FP_number_model: IEEE 754
> > Tag_ABI_align_needed: 8-byte
> > Tag_ABI_align_preserved: 8-byte, except leaf SP
> > Tag_ABI_enum_size: int
> > Tag_CPU_unaligned_access: v6
> > Tag_Virtualization_use: TrustZone
> > -- READELF --
>From gcc-bugs-return-486971-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu May 21 15:29:05 2015
Return-Path: <gcc-bugs-return-486971-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 54749 invoked by alias); 21 May 2015 15:29:05 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 54618 invoked by uid 48); 21 May 2015 15:29:00 -0000
From: "kai-bugs at cats dot ms" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/66246] New: PCH breaks preprocessor
Date: Thu, 21 May 2015 15:29:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: preprocessor
X-Bugzilla-Version: 4.9.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: kai-bugs at cats dot ms
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created
Message-ID: <bug-66246-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-05/txt/msg01811.txt.bz2
Content-length: 22155
https://gcc.gnu.org/bugzilla/show_bug.cgi?idf246
Bug ID: 66246
Summary: PCH breaks preprocessor
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
Assignee: unassigned at gcc dot gnu.org
Reporter: kai-bugs at cats dot ms
Target Milestone: ---
Created attachment 35590
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id5590&actioníit
Header
Test consists of:
- make sure we have no PCH
- compile the source w/o PCH
- compile the PCH
- compile the source w/PCH
As far as I can tell, the reason for the problems is that macros no longer get
expanded
If it matters, this is from the MinGW packaged with Qt 5.4.
$ cat t.sh
#! /bin/bash -x
gcc --version
rm th.hh.gch
g++ -Winvalid-pch -c -save-temps test.cc
g++ -x c++-header -c -save-temps th.hh
g++ -Winvalid-pch -c -save-temps test.cc
$ ./t.sh
+ gcc --version
gcc.exe (i686-posix-dwarf-rev2, Built by MinGW-W64 project) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ rm th.hh.gch
+ g++ -Winvalid-pch -c -save-temps test.cc
+ g++ -x c++-header -c -save-temps th.hh
+ g++ -Winvalid-pch -c -save-temps test.cc
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw.h:13:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:10,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw_secapi.h:51:10: error:
redefinition of 'struct __if_array<true, __dsttype>'
struct __if_array <true, __dsttype> {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw.h:13:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:10,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw_secapi.h:51:10: error:
previous definition of 'struct __if_array<true, __dsttype>'
struct __if_array <true, __dsttype> {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:10:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw.h: In function 'void
__debugbreak()':
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw.h:657:101: error:
redefinition of 'void __debugbreak()'
__MINGW_INTRIN_INLINE void __cdecl __debugbreak(void)
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:10:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/_mingw.h:657:101: note: 'void
__debugbreak()' previously defined here
__MINGW_INTRIN_INLINE void __cdecl __debugbreak(void)
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h: At global scope:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:159:16: error:
redefinition of 'struct localeinfo_struct'
typedef struct localeinfo_struct {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:159:16: error:
previous definition of 'struct localeinfo_struct'
typedef struct localeinfo_struct {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:162:18: error:
invalid type in declaration before ',' token
} _locale_tstruct,*_locale_t;
^
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:162:18: error:
conflicting declaration 'typedef int _locale_tstruct'
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:162:3: note:
previous declaration as 'typedef struct localeinfo_struct _locale_tstruct'
} _locale_tstruct,*_locale_t;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:162:20: error:
conflicting declaration 'typedef int* _locale_t'
} _locale_tstruct,*_locale_t;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:162:20: note:
previous declaration as 'typedef struct localeinfo_struct* _locale_t'
} _locale_tstruct,*_locale_t;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:166:16: error:
redefinition of 'struct tagLC_ID'
typedef struct tagLC_ID {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:166:16: error:
previous definition of 'struct tagLC_ID'
typedef struct tagLC_ID {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:170:8: error:
invalid type in declaration before ',' token
} LC_ID,*LPLC_ID;
^
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:170:8: error:
conflicting declaration 'typedef int LC_ID'
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:170:3: note:
previous declaration as 'typedef struct tagLC_ID LC_ID'
} LC_ID,*LPLC_ID;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:170:10: error:
conflicting declaration 'typedef int* LPLC_ID'
} LC_ID,*LPLC_ID;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:170:10: note:
previous declaration as 'typedef struct tagLC_ID* LPLC_ID'
} LC_ID,*LPLC_ID;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:175:16: error:
redefinition of 'struct threadlocaleinfostruct'
typedef struct threadlocaleinfostruct {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:175:16: error:
previous definition of 'struct threadlocaleinfostruct'
typedef struct threadlocaleinfostruct {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:199:16: error:
invalid type in declaration before ';' token
} threadlocinfo;
^
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:199:16: error:
conflicting declaration 'typedef int threadlocinfo'
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:15:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/crtdefs.h:199:3: note:
previous declaration as 'typedef struct threadlocaleinfostruct threadlocinfo'
} threadlocinfo;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:50:18: error:
redefinition of 'struct _div_t'
typedef struct _div_t {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:50:18: error:
previous definition of 'struct _div_t'
typedef struct _div_t {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:53:10: error: invalid
type in declaration before ';' token
} div_t;
^
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:53:10: error:
conflicting declaration 'typedef int div_t'
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:53:5: note: previous
declaration as 'typedef struct _div_t div_t'
} div_t;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:55:18: error:
redefinition of 'struct _ldiv_t'
typedef struct _ldiv_t {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:55:18: error:
previous definition of 'struct _ldiv_t'
typedef struct _ldiv_t {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:58:11: error: invalid
type in declaration before ';' token
} ldiv_t;
^
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:58:11: error:
conflicting declaration 'typedef int ldiv_t'
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:58:5: note: previous
declaration as 'typedef struct _ldiv_t ldiv_t'
} ldiv_t;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:67:5: error:
conflicting declaration 'typedef struct _LDOUBLE _LDOUBLE'
} _LDOUBLE;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:67:5: note: previous
declaration as 'typedef struct _LDOUBLE _LDOUBLE'
} _LDOUBLE;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:74:5: error:
conflicting declaration 'typedef struct _CRT_DOUBLE _CRT_DOUBLE'
} _CRT_DOUBLE;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:74:5: note: previous
declaration as 'typedef struct _CRT_DOUBLE _CRT_DOUBLE'
} _CRT_DOUBLE;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:78:5: error:
conflicting declaration 'typedef struct _CRT_FLOAT _CRT_FLOAT'
} _CRT_FLOAT;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:78:5: note: previous
declaration as 'typedef struct _CRT_FLOAT _CRT_FLOAT'
} _CRT_FLOAT;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:85:5: error:
conflicting declaration 'typedef struct _LONGDOUBLE _LONGDOUBLE'
} _LONGDOUBLE;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:85:5: note: previous
declaration as 'typedef struct _LONGDOUBLE _LONGDOUBLE'
} _LONGDOUBLE;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:92:5: error:
conflicting declaration 'typedef struct _LDBL12 _LDBL12'
} _LDBL12;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:92:5: note: previous
declaration as 'typedef struct _LDBL12 _LDBL12'
} _LDBL12;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h: In function 'long
long int _abs64(long long int)':
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:335:108: error:
redefinition of 'long long int _abs64(long long int)'
__MINGW_INTRIN_INLINE __int64 __cdecl _abs64(__int64 x) {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:335:108: note: 'long
long int _abs64(long long int)' previously defined here
__MINGW_INTRIN_INLINE __int64 __cdecl _abs64(__int64 x) {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h: At global scope:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:626:57: error:
conflicting declaration 'typedef struct lldiv_t lldiv_t'
typedef struct { __MINGW_EXTENSION long long quot, rem; } lldiv_t;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17:0,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:626:57: note:
previous declaration as 'typedef struct lldiv_t lldiv_t'
typedef struct { __MINGW_EXTENSION long long quot, rem; } lldiv_t;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:667:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/sec_api/stdlib_s.h:49:149:
error: redefinition of 'template<unsigned int __drive_size, unsigned int
__dir_size, unsigned int __name_size, unsigned int __ext_size> errno_t
_splitpath_s(const char*, char (&)[__drive_size], char (&)[__dir_size], char
(&)[__name_size], char (&)[__ext_size])'
__DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t,_splitpath_s,char,_Dest)
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:667:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/sec_api/stdlib_s.h:49:149:
note: 'template<unsigned int __drive_size, unsigned int __dir_size, unsigned
int __name_size, unsigned int __ext_size> errno_t _splitpath_s(const char*,
char (&)[__drive_size], char (&)[__dir_size], char (&)[__name_size], char
(&)[__ext_size])' previously declared here
__DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t,_splitpath_s,char,_Dest)
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:667:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/sec_api/stdlib_s.h:58:149:
error: redefinition of 'template<unsigned int __drive_size, unsigned int
__dir_size, unsigned int __name_size, unsigned int __ext_size> errno_t
_wsplitpath_s(const wchar_t*, wchar_t (&)[__drive_size], wchar_t
(&)[__dir_size], wchar_t (&)[__name_size], wchar_t (&)[__ext_size])'
__DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t,_wsplitpath_s,wchar_t,_Dest)
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:667:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/sec_api/stdlib_s.h:58:149:
note: 'template<unsigned int __drive_size, unsigned int __dir_size, unsigned
int __name_size, unsigned int __ext_size> errno_t _wsplitpath_s(const wchar_t*,
wchar_t (&)[__drive_size], wchar_t (&)[__dir_size], wchar_t (&)[__name_size],
wchar_t (&)[__ext_size])' previously declared here
__DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(errno_t,_wsplitpath_s,wchar_t,_Dest)
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:46:18: error:
redefinition of 'struct _heapinfo'
typedef struct _heapinfo {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:46:18: error:
previous definition of 'struct _heapinfo'
typedef struct _heapinfo {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:50:14: error: invalid
type in declaration before ';' token
} _HEAPINFO;
^
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:50:14: error:
conflicting declaration 'typedef int _HEAPINFO'
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:50:5: note: previous
declaration as 'typedef struct _heapinfo _HEAPINFO'
} _HEAPINFO;
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h: In function 'void*
_MarkAllocaS(void*, unsigned int)':
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:144:25: error:
redefinition of 'void* _MarkAllocaS(void*, unsigned int)'
static __inline void *_MarkAllocaS(void *_Ptr,unsigned int _Marker) {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:144:25: note: 'void*
_MarkAllocaS(void*, unsigned int)' previously defined here
static __inline void *_MarkAllocaS(void *_Ptr,unsigned int _Marker) {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from test.cc:4:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h: In function 'void
_freea(void*)':
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:163:51: error:
redefinition of 'void _freea(void*)'
static __inline void __cdecl _freea(void *_Memory) {
^
In file included from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/stdlib.h:668:0,
from
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/assert.h:17,
from th.hh:1:
C:/Qt/Tools/mingw491_32/i686-w64-mingw32/include/malloc.h:163:51: note: 'void
_freea(void*)' previously defined here
static __inline void __cdecl _freea(void *_Memory) {
^
test.cc: In function 'void f()':
test.cc:14:8: error: '__FILE__' was not declared in this scope
bla();
^
test.cc:14:18: error: '__LINE__' was not declared in this scope
bla();
^
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/66239] Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp]
2015-05-21 10:56 [Bug c++/66239] New: Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp] maciej.andrzejewski at data dot pl
2015-05-21 15:28 ` [Bug c++/66239] " ramana at gcc dot gnu.org
@ 2015-05-21 16:53 ` ktkachov at gcc dot gnu.org
2015-05-21 17:33 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2015-05-21 16:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66239
ktkachov at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ktkachov at gcc dot gnu.org
--- Comment #3 from ktkachov at gcc dot gnu.org ---
FWIW I can't reproduce on a bare-metal arm-none-eabi trunk (i.e. future GCC 6)
With: -mcpu=cortex-a8 -march=armv7-a -mtune=cortex-a8 -mfpu=neon
-mthumb-interwork -mfpu=neon -Wall -Wextra -mfloat-abi=soft prsqrt.c
-specs=rdimon.specs -lm
I get:
3.016621
3.016621
3.016621
3.016621
Note that I also had to add -lm to link the sqrt and sqrtf functions in.
Considering that the -O0 version is the only one that ends up calling the
library functions, perhaps there's something wrong with your math library?
I'm using newlib for arm-none-eabi
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/66239] Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp]
2015-05-21 10:56 [Bug c++/66239] New: Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp] maciej.andrzejewski at data dot pl
2015-05-21 15:28 ` [Bug c++/66239] " ramana at gcc dot gnu.org
2015-05-21 16:53 ` ktkachov at gcc dot gnu.org
@ 2015-05-21 17:33 ` pinskia at gcc dot gnu.org
2015-06-08 15:59 ` maciej.andrzejewski at data dot pl
2015-06-08 15:59 ` maciej.andrzejewski at data dot pl
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-05-21 17:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66239
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2015-05-21
Ever confirmed|0 |1
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to ktkachov from comment #3)
> Considering that the -O0 version is the only one that ends up calling the
> library functions, perhaps there's something wrong with your math library?
> I'm using newlib for arm-none-eabi
Or maybe the libm that is not using the correct ABI. Since you did not place
how you built gcc, it is hard to tell right away.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/66239] Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp]
2015-05-21 10:56 [Bug c++/66239] New: Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp] maciej.andrzejewski at data dot pl
` (3 preceding siblings ...)
2015-06-08 15:59 ` maciej.andrzejewski at data dot pl
@ 2015-06-08 15:59 ` maciej.andrzejewski at data dot pl
4 siblings, 0 replies; 6+ messages in thread
From: maciej.andrzejewski at data dot pl @ 2015-06-08 15:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66239
Maciej Andrzejewski <maciej.andrzejewski at data dot pl> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #5 from Maciej Andrzejewski <maciej.andrzejewski at data dot pl> ---
Libm and other libs have been mixed. Properly compiled toolchain with libs
solved the problem.
Thank you all for assistance!
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/66239] Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp]
2015-05-21 10:56 [Bug c++/66239] New: Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp] maciej.andrzejewski at data dot pl
` (2 preceding siblings ...)
2015-05-21 17:33 ` pinskia at gcc dot gnu.org
@ 2015-06-08 15:59 ` maciej.andrzejewski at data dot pl
2015-06-08 15:59 ` maciej.andrzejewski at data dot pl
4 siblings, 0 replies; 6+ messages in thread
From: maciej.andrzejewski at data dot pl @ 2015-06-08 15:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66239
--- Comment #6 from Maciej Andrzejewski <maciej.andrzejewski at data dot pl> ---
Libm and other libs have been mixed. Properly compiled toolchain with libs
solved the problem.
Thank you all for assistance!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-06-08 15:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-21 10:56 [Bug c++/66239] New: Unoptimized sqrt(float or double) returns wrong values for ARM Cortex-A8 -mfloat-abi=[soft,softfp] maciej.andrzejewski at data dot pl
2015-05-21 15:28 ` [Bug c++/66239] " ramana at gcc dot gnu.org
2015-05-21 16:53 ` ktkachov at gcc dot gnu.org
2015-05-21 17:33 ` pinskia at gcc dot gnu.org
2015-06-08 15:59 ` maciej.andrzejewski at data dot pl
2015-06-08 15:59 ` maciej.andrzejewski at data dot pl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).