bugmake - Bugs: bug #56206, ifndef false positive for exported...


bug #56206: ifndef false positive for exported variable

Submitted by:  Valentin Rusu <valir>
Submitted on:  Wed 24 Apr 2019 03:47:58 PM UTC  
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.2.1 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sun 12 May 2019 10:43:43 PM UTC, comment #2: 

Somehow my previous comment was truncated (I do so HATE Savannah markup :( ):

There is another assignment operator for variables, ‘?=’. This is called a conditional variable
assignment operator, because it only has an effect if the variable is not yet defined.
This statement:

  FOO ?= bar

is exactly equivalent to this (see The origin Function):

  ifeq ($(origin FOO), undefined)
    FOO = bar

Note that a variable set to an empty value is still defined, so ‘?=’ will not set that variable.

Paul D. Smith <psmith>
Project Administrator
Sun 12 May 2019 10:42:06 PM UTC, comment #1: 

This behavior is correct.  The confusion is because the ?= operator and the ifndef operator have different behaviors for variables which are defined to have an empty value.

ifdef/ifndef test whether the expansion of the variable is the empty string or not:

ifndef variable-name

    If the variable variable-name has an empty value, the text-if-true is effective;
    otherwise, the text-if-false, if any, is effective.

However, the ?= operator tests whether the variable is actually defined or not, not whether it has an empty value:

Paul D. Smith <psmith>
Project Administrator
Wed 24 Apr 2019 03:47:58 PM UTC, original submission:  

Platforms: ArchLinux and Fedora 29

We struggled a bit with this one but here is the test case.
Please check the attached makefiles, after placing them together in the same directory.

Test case 1:

# With the files as given here:
$ make all
make -f child.mk all
make[1]: Entering directory ....
make[1]: Leaving directory ....

Now go and modify the files as described in the "child.mk" comments, then run again:

$ make all
make -f child.mk all
make[1]: Entering directory ...
make[1]: ...

As you can see, the TEST_VAR was now empty.

We are not sure here what's the correct behavior. Does the export from the main Makefile defines the variable? Either ways, one of the test cases shows that we are having a bug here.


Valentin Rusu <valir>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #46825:  Makefile added by valir (52B - application/octet-stream)
file #46826:  child.mk added by valir (260B - text/x-makefile)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by valir (Submitted the item)
  • -email is unavailable- added by valir

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-05-12 psmith StatusNone => Not A Bug
        Open/ClosedOpen => Closed
    2019-04-24 valir Attached File- => Added Makefile, #46825
        Attached File- => Added child.mk, #46826
        Carbon-Copy- => Added vlad.brudasca@intel.com

    Back to the top

    Powered by Savane 3.5