🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Ken Basye Mon, 23 Nov 1992 12:29
Make 3.62 bugs
#1140
Author: Ken Basye
Date: Mon, 23 Nov 1992 12:29
95 lines
3129 bytes
I have found what I believe are two bugs (or perhaps limitations) in
GNU make 3.62.  Both bugs concern lack of error detection during the
processing of conditionals.

The first bug is exercised by leaving the ENDIF off of a conditional.
If the conditional has no ELSE, then the error is detected only when
the condition is false.  If there is an ELSE, then the error is
detected when the condition is true.  In either case, if the end of
the file is reached while lines are being ignored, an error is
signalled, whereas if eof is reached while lines are not being
ignored, no error is signaled and lines are all processed.

The second bug is exercised by having a second ELSE following an
IF-ELSE.  This should be an error, but is accepted without complaint,
regardless of whether the condition is true or false.  

ifeq (cond)
    body1
else
    body2
else
    body3
endif

To further confuse things, if cond succeeds, then both body1 and body3
are processed, while if cond fails, then only body2 is processed.  I
discovered these bugs in the process of building a three-way switch,
so that both body2 and body3 were also IF-ENDIF's.  

An example makefile with a correct three-way switch and two fragments
illustrating the bugs follows.  Thanks very much for GNU make and all
the other programs.
    
Sincerely,

kbasye@black.clarku.edu     
Ken Basye
Dept. of Math and CS
Clark University
950 Main St.
Worcester, MA  01610

____________________________________________________________________

# Change this variable to vary conditions
VAR = val3

CC1 = default

# This looks like the correct way to build a three-way switch.
# It works the way it should.
ifeq ($(VAR),val1)
  CC1 = compiler1
else 
  ifeq ($(VAR),val2)
    CC1 = compiler2
  else 
    ifeq ($(VAR),val3)
      CC1 = g++
    endif 
  endif 
endif 


CC2 = default
# This fragment should lose because the first IF has two
# ELSE's.  The second ELSE cannot belong to the second IF, since that
# is terminated by the first ENDIF.  This is accepted silently, and
# the lines following the second ELSE are processed if the first
# condition is true.  In this case, this has no effect.
ifeq ($(VAR),val1)
  CC2 = compiler1
else 
  ifeq ($(VAR),val2)
    CC2 = compiler2
  endif
else
  ifeq ($(VAR),val3)
    CC2 = g++
  endif
endif

CC3 = default

# This fragment should lose because there is no ENDIF for the IF
# It *does* lose if the test succeeds, but not if it fails.  This
# behaviour is reversed if the ELSE is removed.
#ifeq ($(VAR),val1)
#  CC3 = compiler1
#else 
#  CC3 = g++


test : 
	echo $(VAR) $(CC1) $(CC2) $(CC3)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads