NetBSD Problem Report #53146

From  Mon Apr  2 04:53:36 2018
Return-Path: <>
Received: from ( [])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "", Issuer " CA" (not verified))
	by (Postfix) with ESMTPS id CEF2B7A1CC
	for <>; Mon,  2 Apr 2018 04:53:35 +0000 (UTC)
Message-Id: <>
Date: Mon,  2 Apr 2018 04:53:35 +0000 (UTC)
Subject: make: .for loop binder names aren't expanded
X-Send-Pr-Version: 3.95

>Number:         53146
>Category:       toolchain
>Synopsis:       make: .for loop binder names aren't expanded
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 02 04:55:00 +0000 2018
>Last-Modified:  Mon Apr 02 06:25:44 +0000 2018
>Originator:     David A. Holland
>Release:        NetBSD 8.99.8 (20171205)
System: NetBSD valkyrie 8.99.8 NetBSD 8.99.8 (VALKYRIE) #24: Tue Dec  5 17:30:57 EST 2017  dholland@valkyrie:/usr/src/sys/arch/amd64/compile/VALKYRIE amd64
Architecture: x86_64
Machine: amd64

In ordinary assignments the variable name can be supplied as a
variable expansion:

                echo $(bar)

prints "baz".

However, this is not accepted in a .for loop. The name becomes the
string formed by the variable reference itself.

        .for $(FOO) in a b
                echo "$(FOO)" , "$(foo)" , "$($(FOO))"
prints (with make -n)
        echo "foo" , "" , "a"
        echo "foo" , "" , "b"

What seems to be happening is that the loop binds a variable named
"$(FOO)", so no variable "foo" is bound; then when make goes to
evaluate $($(FOO)) it finds that "FOO" is a variable but not a loop
variable, so it doesn't expand it yet; but then it sees that "$(FOO)"
is a loop variable and expands that, so we get the loop values in the
third print even though one might expect $($(FOO)) to evaluate to the
same thing as $(foo).


as above.


Probably for-loop binders should be allowed to be named by variable
expansions like regular assignments; that is, the for code should do
variable expansion on the binder names. This seems like a wild thing
to do, but there doesn't seem to be any obvious reason to forbid it.

Otherwise we'd want to look for variable expansions in there and error
on them. The current behavior is clearly undesirable.

(also variable names in general shouldn't be allowed to contain "$",
but that's a broader issue)




NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD:,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.