Compiler error: argument of type "VALUE *" is incompatible with parameter of type "VALUE"

I'm trying to build release 1.8.2 on a POSIX (1 and 2) based
environment but have encountered a number of the following errors:

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3206: error(252): argument of type
          "VALUE *" is incompatible with parameter of type "VALUE"

Thanks for the help,

We can't help you unless you provide more information. What OS?
Compiler? Configuration options? etc etc
etc. What you provide above isn't enough.

···

On May 5, 2005, at 2:44 PM, me2faster@excite.com wrote:

--
ryand-ruby@zenspider.com - Seattle.rb -
http://www.zenspider.com/seattle.rb
http://blog.zenspider.com/ - http://rubyforge.org/projects/ruby2c
-----------------------------------------------------------------

I'm trying to build on a Tandem (now HP) NonStop server, under a POSIX
environment. c89 is the C compiler that conforms to the 1989 C standard
(not c99). Here's my 'config.h':

#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define HAVE_LONG_LONG 1
#define HAVE_OFF_T 1
#define SIZEOF_INT 4
#define SIZEOF_SHORT 2
#define SIZEOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define SIZEOF___INT64 0
#define SIZEOF_OFF_T 4
#define SIZEOF_VOIDP 4
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8
#define SIZEOF_TIME_T 4
#define HAVE_PROTOTYPES 1
#define TOKEN_PASTE(x,y) x##y
#define HAVE_STDARG_PROTOTYPES 1
#define NORETURN(x) x
#define HAVE_DECL_SYS_NERR 0
#define HAVE_DIRENT_H 1
#define STDC_HEADERS 1
#define HAVE_SYS_WAIT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_UNISTD_H 1
#define HAVE_LIMITS_H 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_FCNTL_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TIMES_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_PWD_H 1
#define HAVE_GRP_H 1
#define HAVE_UTIME_H 1
#define HAVE_MEMORY_H 1
#define HAVE_SYS_RESOURCE_H 1
#define HAVE_NETINET_IN_SYSTM_H 1
#define HAVE_FLOAT_H 1
#define HAVE_IEEEFP_H 1
#define HAVE_STRUCT_STAT_ST_RDEV 1
#define HAVE_ST_RDEV 1
#define GETGROUPS_T gid_t
#define RETSIGTYPE void
#define C_ALLOCA 1
#define STACK_DIRECTION -1
#define HAVE_DUP2 1
#define HAVE_MEMMOVE 1
#define HAVE_MKDIR 1
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_STRERROR 1
#define HAVE_STRFTIME 1
#define HAVE_STRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOUL 1
#define HAVE_CRYPT 1
#define HAVE_VSNPRINTF 1
#define HAVE_ISNAN 1
#define HAVE_FINITE 1
#define HAVE_HYPOT 1
#define HAVE_ACOSH 1
#define HAVE_ERF 1
#define HAVE_FMOD 1
#define HAVE_WAITPID 1
#define HAVE_CHROOT 1
#define HAVE_FSYNC 1
#define HAVE_GETCWD 1
#define HAVE_TIMES 1
#define HAVE_FCNTL 1
#define HAVE_LSTAT 1
#define HAVE_SYMLINK 1
#define HAVE_READLINK 1
#define HAVE_PAUSE 1
#define HAVE_GETPGRP 1
#define HAVE_GETPGID 1
#define HAVE_SETPGID 1
#define HAVE_GETGROUPS 1
#define HAVE_GETPRIORITY 1
#define HAVE_SIGPROCMASK 1
#define HAVE_SIGACTION 1
#define HAVE__SETJMP 1
#define HAVE_SETSID 1
#define HAVE_TELLDIR 1
#define HAVE_SEEKDIR 1
#define HAVE_MKTIME 1
#define HAVE_COSH 1
#define HAVE_SINH 1
#define HAVE_TANH 1
#define HAVE_SETUID 1
#define HAVE_SETGID 1
#define HAVE_TZNAME 1
#define HAVE_DAYLIGHT 1
#define NEGATIVE_TIME_T 1
#define POSIX_SIGNAL 1
#define GETPGRP_VOID 1
#define SETPGRP_VOID 1
#define WORDS_BIGENDIAN 1
#define __CHAR_UNSIGNED__ 1
#ifndef __cplusplus
#define inline
#endif
#define RSHIFT(x,y) ((x)>>(int)y)
#define FILE_COUNT _cnt
#define FILE_READPTR _ptr
#define NEED_IO_SEEK_BETWEEN_RW 1
#define STACK_GROW_DIRECTION -1
#define DEFAULT_KCODE KCODE_NONE
#define USE_ELF 1
#define DLEXT ".so"
#define RUBY_LIB "/usr/local/lib/ruby/1.8"
#define RUBY_SITE_LIB "/usr/local/lib/ruby/site_ruby"
#define RUBY_SITE_LIB2 "/usr/local/lib/ruby/site_ruby/1.8"
#define RUBY_PLATFORM "nsr-nsk"
#define RUBY_ARCHLIB "/usr/local/lib/ruby/1.8/nsr-nsk"
#define RUBY_SITE_ARCHLIB "/usr/local/lib/ruby/site_ruby/1.8/nsr-nsk"

Hi,

At Fri, 6 May 2005 16:29:32 +0900,
me2faster@excite.com wrote in [ruby-talk:141368]:

I'm trying to build on a Tandem (now HP) NonStop server, under a POSIX
environment. c89 is the C compiler that conforms to the 1989 C standard
(not c99). Here's my 'config.h':

Does this patch help?

Index: eval.c

···

===================================================================
RCS file: /cvs/ruby/src/ruby/eval.c,v
retrieving revision 1.616.2.90
diff -U2 -p -r1.616.2.90 eval.c
--- eval.c 7 Apr 2005 08:47:04 -0000 1.616.2.90
+++ eval.c 7 May 2005 16:25:32 -0000
@@ -2105,5 +2105,5 @@ copy_node_scope(node, rval)
# define TMP_PROTECT NODE * volatile tmp__protect_tmp=0
# define TMP_ALLOC(n) \
- (tmp__protect_tmp = rb_node_newnode(NODE_ALLOCA, \
+ (tmp__protect_tmp = NEW_NODE(NODE_ALLOCA, \
            ALLOC_N(VALUE,n),tmp__protect_tmp,n), \
      (void*)tmp__protect_tmp->nd_head)

--
Nobu Nakada

Nope, here are the errors with the patched 'eval.c':

/usr/bin/c89 -g -Wnowarn -I. -I. -c eval.c
            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3217: error(252): argument of type
          "void *" is incompatible with parameter of type "VALUE"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3217: error(250): too few arguments in
          function call

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3217: error(112): expected a ")"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3217: error(112): expected a ")"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3217: error(611): a value of type
          "NODE *" cannot be assigned to an entity of type "VALUE *"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3235: error(252): argument of type
          "void *" is incompatible with parameter of type "VALUE"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3235: error(250): too few arguments in
          function call

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3235: error(112): expected a ")"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3235: error(112): expected a ")"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3235: error(611): a value of type
          "NODE *" cannot be assigned to an entity of type "VALUE *"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3250: error(252): argument of type
          "void *" is incompatible with parameter of type "VALUE"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3250: error(250): too few arguments in
          function call

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3250: error(112): expected a ")"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3250: error(112): expected a ")"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3250: error(611): a value of type
          "NODE *" cannot be assigned to an entity of type "VALUE *"

                SETUP_ARGS(node->nd_args);
                ^
"/home/ruby-1.8.2/eval.c", line 3286: error(252): argument of type
          "void *" is incompatible with parameter of type "VALUE"

                SETUP_ARGS(node->nd_args);
                ^
"/home/ruby-1.8.2/eval.c", line 3286: error(250): too few arguments in
          function call

                SETUP_ARGS(node->nd_args);
                ^
"/home/ruby-1.8.2/eval.c", line 3286: error(112): expected a ")"

                SETUP_ARGS(node->nd_args);
                ^
"/home/ruby-1.8.2/eval.c", line 3286: error(112): expected a ")"

                SETUP_ARGS(node->nd_args);
                ^
"/home/ruby-1.8.2/eval.c", line 3286: error(611): a value of type
          "NODE *" cannot be assigned to an entity of type "VALUE *"

            SETUP_ARGS0(node->nd_args->nd_next, node->nd_args->nd_alen
- 1);
            ^
"/home/ruby-1.8.2/eval.c", line 3343: error(252): argument of type
          "void *" is incompatible with parameter of type "VALUE"

            SETUP_ARGS0(node->nd_args->nd_next, node->nd_args->nd_alen
- 1);
            ^
"/home/ruby-1.8.2/eval.c", line 3343: error(250): too few arguments in
          function call

            SETUP_ARGS0(node->nd_args->nd_next, node->nd_args->nd_alen
- 1);
            ^
"/home/ruby-1.8.2/eval.c", line 3343: error(112): expected a ")"

            SETUP_ARGS0(node->nd_args->nd_next, node->nd_args->nd_alen
- 1);
            ^
"/home/ruby-1.8.2/eval.c", line 3343: error(112): expected a ")"

            SETUP_ARGS0(node->nd_args->nd_next, node->nd_args->nd_alen
- 1);
            ^
"/home/ruby-1.8.2/eval.c", line 3343: error(611): a value of type
          "NODE *" cannot be assigned to an entity of type "VALUE *"

        VALUE *vars = TMP_ALLOC(node->nd_tbl[0]+1);
                      ^
"/home/ruby-1.8.2/eval.c", line 3929: error(252): argument of type
          "void *" is incompatible with parameter of type "VALUE"

        VALUE *vars = TMP_ALLOC(node->nd_tbl[0]+1);
                                                  ^
"/home/ruby-1.8.2/eval.c", line 3929: error(250): too few arguments in
          function call

        VALUE *vars = TMP_ALLOC(node->nd_tbl[0]+1);
                                                  ^
"/home/ruby-1.8.2/eval.c", line 3929: error(112): expected a ")"

        VALUE *vars = TMP_ALLOC(node->nd_tbl[0]+1);
                                                  ^
"/home/ruby-1.8.2/eval.c", line 3929: error(112): expected a ")"

        VALUE *vars = TMP_ALLOC(node->nd_tbl[0]+1);
                      ^
"/home/ruby-1.8.2/eval.c", line 3929: error(232): a value of type
          "NODE *" cannot be used to initialize an entity of type
"VALUE *"

      SETUP_ARGS(node->nd_args);
      ^
"/home/ruby-1.8.2/eval.c", line 5084: error(252): argument of type
          "void *" is incompatible with parameter of type "VALUE"

      SETUP_ARGS(node->nd_args);
      ^
"/home/ruby-1.8.2/eval.c", line 5084: error(250): too few arguments in
          function call

      SETUP_ARGS(node->nd_args);
      ^
"/home/ruby-1.8.2/eval.c", line 5084: error(112): expected a ")"

      SETUP_ARGS(node->nd_args);
      ^
"/home/ruby-1.8.2/eval.c", line 5084: error(112): expected a ")"

      SETUP_ARGS(node->nd_args);
      ^
"/home/ruby-1.8.2/eval.c", line 5084: error(611): a value of type
          "NODE *" cannot be assigned to an entity of type "VALUE *"

                local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
                             ^
"/home/ruby-1.8.2/eval.c", line 5574: error(252): argument of type
          "void *" is incompatible with parameter of type "VALUE"

                local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
                                                         ^
"/home/ruby-1.8.2/eval.c", line 5574: error(250): too few arguments in
          function call

                local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
                                                         ^
"/home/ruby-1.8.2/eval.c", line 5574: error(112): expected a ")"

                local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
                                                         ^
"/home/ruby-1.8.2/eval.c", line 5574: error(112): expected a ")"

                local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
                           ^
"/home/ruby-1.8.2/eval.c", line 5574: error(611): a value of type
          "NODE *" cannot be assigned to an entity of type "VALUE *"

40 errors detected in the compilation of "eval.c".
c89: /usr/cmplr/ccombe exited, returning 2.
*** Error code 1

Stop.

Hi,

At Tue, 10 May 2005 03:29:24 +0900,
me2faster@excite.com wrote in [ruby-talk:141872]:

Nope, here are the errors with the patched 'eval.c':

Hmmm, the warnings disappeared by the patch, on gcc.

"/home/ruby-1.8.2/eval.c", line 3217: error(112): expected a ")"

            SETUP_ARGS(node->nd_args);
            ^

This error occurred before the patch? If no, ensure if the
patch is applied correctly, please.

40 errors detected in the compilation of "eval.c".
c89: /usr/cmplr/ccombe exited, returning 2.

What an eccentric compiler... It seems like rather C++ compiler.

···

--
Nobu Nakada

The initial diagnostics were errors, too, not warnings. And yes, they
were related to the SETUP_ARGS(...) macro. Before I even posted this
issue, I narrowed down the pre-processed code and discovered that in
fact there was an incompatible type being passed by the caller to the
callee. I too can build this successfully under gcc version 3.3.3, but
that does not help me with building a load file for the targeted
NonStop platform.

Hi,

At Tue, 10 May 2005 09:04:23 +0900,
me2faster@excite.com wrote in [ruby-talk:141918]:

The initial diagnostics were errors, too, not warnings.

I knew they were errors, so called "eccentric".

And yes, they were related to the SETUP_ARGS(...) macro.

What I asked in [ruby-talk:141916] was if the error(112):
`expected a ")"' also occurred with the original eval.c. If
yes, show the pre-processed code. Otherwise, the patch is
considered not applied correctly.

···

--
Nobu Nakada

Yes, the patch was not applied correctly, since I had both the
following lines, rather than just the second one:

....
- (tmp__protect_tmp = rb_node_newnode(NODE_ALLOCA,
\
+ (tmp__protect_tmp = NEW_NODE(NODE_ALLOCA,
\
....

However, the original errors persist:

/usr/bin/c89 -g -Wnowarn -I. -I. -c eval.c
            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3206: error(252): argument of type
          "VALUE *" is incompatible with parameter of type "VALUE"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3206: error(252): argument of type
          "NODE *" is incompatible with parameter of type "VALUE"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3224: error(252): argument of type
          "VALUE *" is incompatible with parameter of type "VALUE"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3224: error(252): argument of type
          "NODE *" is incompatible with parameter of type "VALUE"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3239: error(252): argument of type
          "VALUE *" is incompatible with parameter of type "VALUE"

            SETUP_ARGS(node->nd_args);
            ^
"/home/ruby-1.8.2/eval.c", line 3239: error(252): argument of type
          "NODE *" is incompatible with parameter of type "VALUE"

                SETUP_ARGS(node->nd_args);
                ^
"/home/ruby-1.8.2/eval.c", line 3275: error(252): argument of type
          "VALUE *" is incompatible with parameter of type "VALUE"

                SETUP_ARGS(node->nd_args);
                ^
"/home/ruby-1.8.2/eval.c", line 3275: error(252): argument of type
          "NODE *" is incompatible with parameter of type "VALUE"

            SETUP_ARGS0(node->nd_args->nd_next, node->nd_args->nd_alen
- 1);
            ^
"/home/ruby-1.8.2/eval.c", line 3332: error(252): argument of type
          "VALUE *" is incompatible with parameter of type "VALUE"

            SETUP_ARGS0(node->nd_args->nd_next, node->nd_args->nd_alen
- 1);
            ^
"/home/ruby-1.8.2/eval.c", line 3332: error(252): argument of type
          "NODE *" is incompatible with parameter of type "VALUE"

        VALUE *vars = TMP_ALLOC(node->nd_tbl[0]+1);
                      ^
"/home/ruby-1.8.2/eval.c", line 3918: error(252): argument of type
          "VALUE *" is incompatible with parameter of type "VALUE"

        VALUE *vars = TMP_ALLOC(node->nd_tbl[0]+1);
                      ^
"/home/ruby-1.8.2/eval.c", line 3918: error(252): argument of type
          "NODE *" is incompatible with parameter of type "VALUE"

      SETUP_ARGS(node->nd_args);
      ^
"/home/ruby-1.8.2/eval.c", line 5073: error(252): argument of type
          "VALUE *" is incompatible with parameter of type "VALUE"

      SETUP_ARGS(node->nd_args);
      ^
"/home/ruby-1.8.2/eval.c", line 5073: error(252): argument of type
          "NODE *" is incompatible with parameter of type "VALUE"

                local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
                             ^
"/home/ruby-1.8.2/eval.c", line 5563: error(252): argument of type
          "VALUE *" is incompatible with parameter of type "VALUE"

                local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
                             ^
"/home/ruby-1.8.2/eval.c", line 5563: error(252): argument of type
          "NODE *" is incompatible with parameter of type "VALUE"

16 errors detected in the compilation of "eval.c".

And at least the first error (and I suspect the subsequent errors, too)
related to the following pre-processed code appears to be valid:

                 argv = (tmp__protect_tmp =
rb_node_newnode(NODE_ALLOCA, (VALUE*
)ruby_xmalloc(sizeof(VALUE)*(argc)),tmp__protect_tmp,argc),
(void*)tmp__protect_
tmp->u1 . node);

^
"/home/ruby-1.8.2/temp/eval.c", line 5164: error(252): argument of
          type "VALUE *" is incompatible with parameter of type "VALUE"

Hi,

At Tue, 10 May 2005 10:04:30 +0900,
me2faster@excite.com wrote in [ruby-talk:141925]:

Yes, the patch was not applied correctly, since I had both the
following lines, rather than just the second one:

....
- (tmp__protect_tmp = rb_node_newnode(NODE_ALLOCA, \
+ (tmp__protect_tmp = NEW_NODE(NODE_ALLOCA, \
....

However, the original errors persist:

Even if you deleted the first `rb_node_newnode' line and `+' sign at
the beginning of the second one?

And at least the first error (and I suspect the subsequent errors, too)
related to the following pre-processed code appears to be valid:

                 argv = (tmp__protect_tmp =
rb_node_newnode(NODE_ALLOCA, (VALUE*
)ruby_xmalloc(sizeof(VALUE)*(argc)),tmp__protect_tmp,argc),
(void*)tmp__protect_
tmp->u1 . node);

^
"/home/ruby-1.8.2/temp/eval.c", line 5164: error(252): argument of
          type "VALUE *" is incompatible with parameter of type "VALUE"

The patch would make the latter three arguments of rb_node_newnode()
cast to VALUE.

···

--
Nobu Nakada

Yes, I cleaned up the macro a bit, and your patch now works:

....
#ifdef C_ALLOCA
# define TMP_PROTECT NODE * volatile tmp__protect_tmp=0

# define TMP_ALLOC(n) \
    (tmp__protect_tmp = NEW_NODE(NODE_ALLOCA, \
       ALLOC_N(VALUE,n),tmp__protect_tmp,n), \
      (void*)tmp__protect_tmp->nd_head)

#else
# define TMP_PROTECT typedef int foobazzz
....

Will this patch be integrated into the 1.8.2 source so that myself and
others won't run into the same problem in the future? If it's
integrated into the source, will it need any special command-line
switches or in-source #defines to be invoked?

Thanks !!

Hi,

At Tue, 10 May 2005 16:49:33 +0900,
me2faster@excite.com wrote in [ruby-talk:141960]:

Will this patch be integrated into the 1.8.2 source so that myself and
others won't run into the same problem in the future? If it's
integrated into the source, will it need any special command-line
switches or in-source #defines to be invoked?

Committed. Just recompile is needed.

···

--
Nobu Nakada