help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

make and c++ exceptions


From: Steve Hutton
Subject: make and c++ exceptions
Date: Sat, 6 Sep 2003 12:31:41 -0400
User-agent: KMail/1.5.1

I noticed that my automake-generated makefile was reporting
"FAIL" for make check tests that throw (and catch) C++ exceptions,
even when they return 0.

I have extracted and simplified the make-check target into a standalone
Makefile which reproduces the behavior - that is, the simple test program
below called "return0throw" is seen by make as returning 134, instead of 0.
A standalone bash script confirms that bash sees a return of 0.

Can anyone reproduce and/or explain this? 

$ more Makefile
TESTS=return1 return99 return0 return0throw

all: $(TESTS)
        list='$(TESTS)'; \
        if test -n "$$list"; then \
          for tst in $$list; do \
            if ./$$tst; then \
                echo "PASS: $$tst $$?"; \
            else \
                echo "FAIL: $$tst $$?"; \
            fi; \
          done; \
        fi;

Simple test programs:

$ more return1.cpp
int main()
{
  return 1;
}

$ more return0.cpp
int main()
{
 return 0;
}

$ more return99.cpp
int main()
{
  return 99;
}

$ more return0throw.cpp
void throwSomething()
{
   throw("hello");
}

int main()
{
  try
  {
     throwSomething();
  }
  catch(...)
  {

  }
  return 0;
}

Now run make to see that it believes the last
program is returning 134(!?) instead of 0:

$ make
list='return1 return99 return0 return0throw'; \
if test -n "$list"; then \
  for tst in $list; do \
    if ./$tst; then \
        echo "PASS: $tst $?"; \
    else \
        echo "FAIL: $tst $?"; \
    fi; \
  done; \
        fi;
FAIL: return1 1
FAIL: return99 99
PASS: return0 0
FAIL: return0throw 134

A similar bash script returns the results I expect:

$ test.sh
#!/bin/sh

TST=return1
echo $TST
./$TST
echo $?

TST=return0
echo $TST
./$TST
echo $?

TST=return99
echo $TST
./$TST
echo $?

TST=return0throw
echo $TST
./$TST
echo $?

$ ./test.sh
return1
1
return0
0
return99
99
return0throw
0

Thanks,
Steve




reply via email to

[Prev in Thread] Current Thread [Next in Thread]