Issue 1:
The following code:

subroutine s(n, a)
integer :: n, a(1:2**n)
end

causes f2py to crash with:

/tmp/tmprxk_Ew/src.linux-x86_64-2.7/f2py_bugmodule.c: In function ‘f2py_rout_f2py_bug_s’:

/tmp/tmprxk_Ew/src.linux-x86_64-2.7/f2py_bugmodule.c:217:15: error: invalid type argument of unary ‘’ (have ‘int’)

a_Dims[0]=2*n;

^

Original report: http://stackoverflow.com/questions/35156750/f2py-invalid-type-argument-of-unary

Full output:

f2py -c f2py_bug.f90 -m f2py_bug

running build

running config_cc

unifing config_cc, config, build_clib, build_ext, build commands --compiler options

running config_fc

unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options

running build_src

build_src

building extension "f2py_bug" sources

f2py options: []

f2py:> /tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c

creating /tmp/tmplNikU7/src.linux-x86_64-2.7

Reading fortran codes...

Reading file 'f2py_bug.f90' (format:free)

Post-processing...

Block: f2py_bug

Block: s

Post-processing (stage 2)...

Building modules...

Building module "f2py_bug"...

Constructing wrapper function "s"...

s(n,a)

Wrote C/API module "f2py_bug" to file "/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c"

adding '/tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.c' to sources.

adding '/tmp/tmplNikU7/src.linux-x86_64-2.7' to include_dirs.

copying /usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /tmp/tmplNikU7/src.linux-x86_64-2.7

copying /usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /tmp/tmplNikU7/src.linux-x86_64-2.7

build_src: building npy-pkg config files

running build_ext

customize UnixCCompiler

customize UnixCCompiler using build_ext

customize Gnu95FCompiler

Found executable /usr/bin/gfortran

customize Gnu95FCompiler

customize Gnu95FCompiler using build_ext

building 'f2py_bug' extension

compiling C sources

C compiler: gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC

creating /tmp/tmplNikU7/tmp

creating /tmp/tmplNikU7/tmp/tmplNikU7

creating /tmp/tmplNikU7/tmp/tmplNikU7/src.linux-x86_64-2.7

compile options: '-I/tmp/tmplNikU7/src.linux-x86_64-2.7 -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c'

gcc: /tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.c

In file included from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1781:0,

from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,

from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,

from /tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.h:13,

from /tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.c:2:

/usr/lib64/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

#warning "Using deprecated NumPy API, disable it by "

^

gcc: /tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c

In file included from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1781:0,

from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,

from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,

from /tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.h:13,

from /tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:19:

/usr/lib64/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

#warning "Using deprecated NumPy API, disable it by "

^

/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c: In function ‘f2py_rout_f2py_bug_s’:

/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:217:15: error: invalid type argument of unary ‘’ (have ‘int’)

a_Dims[0]=2__n;

^

/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c: At top level:

/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:105:12: warning: ‘f2py_size’ defined but not used [-Wunused-function]

static int f2py_size(PyArrayObject var, ...)

^

In file included from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1781:0,

from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,

from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,

from /tmp/tmplNikU7/src.linux-x86_64-2.7/fortranobject.h:13,

from /tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:19:

/usr/lib64/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

#warning "Using deprecated NumPy API, disable it by "

^

/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c: In function ‘f2py_rout_f2py_bug_s’:

/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:217:15: error: invalid type argument of unary ‘’ (have ‘int’)

a_Dims[0]=2__n;

^

/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c: At top level:

/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c:105:12: warning: ‘f2py_size’ defined but not used [-Wunused-function]

static int f2py_size(PyArrayObject var, ...)

^

error: Command "gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -I/tmp/tmplNikU7/src.linux-x86_64-2.7 -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c /tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.c -o /tmp/tmplNikU7/tmp/tmplNikU7/src.linux-x86_64-2.7/f2py_bugmodule.o" failed with exit status 1

Issue 2:
When I constructed an array named list in fortran, like code shown below:

subroutine blah(list, n)
integer, intent(in) :: n
real, intent(out) :: list(2*n,0:2**n)

list = 1.0

end subroutine

I encountered the following error, which seems to treat exponentiation as a pointer. Any ideas how to get rid of it? Thanks!

/tmp/tmpHYL2Dx/src.linux-x86_64-2.7/cmmodule.c:216:37: error: invalid type argument of unary ‘*’ (have ‘int’)
list_Dims[0]=2 * n,list_Dims[1]=2**n+1;
^