home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.utils.bug
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!black.clarku.edu!kbasye
- From: kbasye@black.clarku.edu (Ken Basye)
- Subject: Make 3.62 bugs
- Message-ID: <9211232229.AA26709@black.clarku.edu>
- Sender: gnulists@ai.mit.edu
- Reply-To: kbasye@black.clarku.edu
- Organization: GNUs Not Usenet
- Distribution: gnu
- Date: Mon, 23 Nov 1992 12:29:37 GMT
- Approved: bug-gnu-utils@prep.ai.mit.edu
- Lines: 101
-
- 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)
-
-
-
-
-
-
-