Re: behavior-preserving optimization in C, was compiler bugs

anton@mips.complang.tuwien.ac.at (Anton Ertl)
Mon, 25 May 2009 18:01:21 GMT

          From comp.compilers

Related articles
[23 earlier articles]
Re: behavior-preserving optimization in C, was compiler bugs anton@mips.complang.tuwien.ac.at (2009-05-21)
Re: behavior-preserving optimization in C, was compiler bugs anton@mips.complang.tuwien.ac.at (2009-05-21)
Re: behavior-preserving optimization in C, was compiler bugs bear@sonic.net (Ray) (2009-05-21)
Re: behavior-preserving optimization in C, was compiler bugs Jan.Vorbrueggen@thomson.net (=?ISO-8859-15?Q?Jan_Vorbr=FCggen?=) (2009-05-22)
Re: behavior-preserving optimization in C, was compiler bugs gneuner2@comcast.net (George Neuner) (2009-05-24)
Re: behavior-preserving optimization in C, was compiler bugs DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-05-25)
Re: behavior-preserving optimization in C, was compiler bugs anton@mips.complang.tuwien.ac.at (2009-05-25)
Re: behavior-preserving optimization in C, was compiler bugs ian@airs.com (Ian Lance Taylor) (2009-05-25)
Re: behavior-preserving optimization in C, was compiler bugs gneuner2@comcast.net (George Neuner) (2009-05-25)
Re: behavior-preserving optimization in C, was compiler bugs DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-05-29)
Re: behavior-preserving optimization in C, was compiler bugs dave.thompson2@verizon.net (David Thompson) (2009-06-15)
| List of all articles for this month |

From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.compilers
Date: Mon, 25 May 2009 18:01:21 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 09-04-072 09-04-086 09-05-010 09-05-022 09-05-028 09-05-038 09-05-039 09-05-050 09-05-055 09-05-065 09-05-069 09-05-073 09-05-087 09-05-110
Keywords: optimize, linker
Posted-Date: 25 May 2009 19:50:36 EDT

George Neuner <gneuner2@comcast.net> writes:
>C does not allow either duplicate definitions or multiple definitions
>of the same named object in any name overloading class (of which the
>"top level", ie. global names, is one). You can have duplicated
>_declarations_, but not duplicated _definitions_.
...
>But for the sake of a discussion about compilers, how would you
>handle the situation if it were up to you?


What I expected is that the linker complains about duplicate symbols
(irrespective of optimization level). I was very surprised that GNU
ld produced only warnings for the example given, and that linking
succeeded. I wonder why this does not happen; two explanations come
to mind:


* There are important programs around that use definition syntax
(i.e., no extern) for global variable declarations and C compiler
writers want their compilers to work on these programs.


* There is no good way to let the linker work the way I expect it;
maybe you cannot have strong symbols in the bss segment or something
(although I would find that surprising).


- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/
[I think it's a historical artifact. The early linkage behavior of C
was based on Fortran COMMON statements, where you could have multiple
uninitialized versions and optionally one initialized (BLOCK DATA)
version. -John]







Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.