No Subject

Utilisateur FNET bravier@dassault-aviation.fr
Fri Feb 6 08:31:00 GMT 1998


===============================================================================
This is a bug report for egcs-1.0.1/gcc:
===============================================================================

Thierry Bravier              Dassault Aviation - DGT / DPR / DESA
78, Quai Marcel Dassault       F-92214 Saint-Cloud Cedex - France
Telephone : (33) 01 47 11 53 07   Telecopie : (33) 01 47 11 52 83
E-Mail :              mailto:thierry.bravier@dassault-aviation.fr

===============================================================================
Local configuration:
===============================================================================
% uname -a
SunOS scdprs20 5.5.1 Generic sun4u sparc SUNW,Ultra-2

-------------------------------------------------------------------------------
% egcs-g++ -v
Reading specs from /logiciel/GNU/LOCAL/gcc/egcs-1.0.1/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.23/specs
gcc version egcs-2.90.23 980102 (egcs-1.0.1 release)

-------------------------------------------------------------------------------
egcs-1.0.1 was installed with:

% SOURCES_EGCS=/logiciel/GNU/SOURCES/gcc/egcs-1.0.1/distrib
% LOCAL_EGCS=/logiciel/GNU/LOCAL/gcc/egcs-1.0.1
% OBJ_EGCS=/logiciel/commun/egcs-1.0.1.SunOS.5.5.1
% cd ${OBJ_EGCS}
% ${SOURCES_EGCS}/configure  \
   --prefix=${LOCAL_EGCS} \
   --with-local-prefix=${LOCAL_EGCS} \
   --with-gxx-include-dir=${LOCAL_EGCS}/include/g++
% gmake bootstrap CC=gcc
% gmake install

===============================================================================
Bug description and report:
===============================================================================
When using nested functions together with blocks returning values, the
-O3 optimizer seems to produce erroneous code.

As shown in the code, `&f' generates correct code but `f' (taken as a
function pointer) does not.

Moreover, the -O2 optimisation is correct.

Contextual considerations (useless to fix the bug):
Although my example is a strange looking one, this technique has proved very
useful to me to simulate LISP lambda's. It makes it possible to define a
macro LAMBDA defining a local function that can be directly used as a function
pointer.

PS: Thank you for your great work, I hope this mail will help.
    Could you please let me know about this mail and its implications.

-------------------------------------------------------------------------------
% cat -n nested-function.c
     1	main () {
     2	  ({
     3	    void f () {}
     4	    f;			/* strangely, `&f' is accepted ! */
     5	  });
     6	}

-------------------------------------------------------------------------------
% egcs-gcc -E nested-function.c
# 1 "nested-function.c"
main () {
  ({
    void f () {}
    f;			 
  });
}

-------------------------------------------------------------------------------
% egcs-gcc -o nested-function-O2 -O2 nested-function.c
% ./nested-function-O2
% egcs-gcc -o nested-function-O3 -O3 nested-function.c
Undefined			first referenced
 symbol  			    in file
f.2                                 /var/tmp/cca001ap1.o
ld: fatal: Symbol referencing errors. No output written to nested-function-O3
collect2: ld returned 1 exit status

===============================================================================



More information about the Gcc-bugs mailing list