bugGNU Octave - Bugs: bug #60162, Conflicting types for...

 
 

bug #60162: Conflicting types for octave_iconv_open_wrapper and octave_iconv_close_wrapper

Submitted by:  Michele <michele31415>
Submitted on:  Wed 03 Mar 2021 04:43:44 PM UTC  
 
Category:  Configuration and Build System Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  Michele Open/Closed:  Closed
Release:  6.2.0 Operating System:  Solaris/SunOS

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

( Jump to the original submission)

Thu 04 Mar 2021 08:05:53 AM UTC, comment #10: 

Thanks for testing.

I pushed the change to stable here:
https://hg.savannah.gnu.org/hgweb/octave/rev/69087119ee84

Closing as fixed.

Markus Mützel <mmuetzel>
Project Member
Thu 04 Mar 2021 07:37:05 AM UTC, comment #9: 

To make it easier to find it in the future, the related thread on the discourse forum:
https://octave.discourse.group/t/build-6-2-0-fails-on-solaris/828

Markus Mützel <mmuetzel>
Project Member
Thu 04 Mar 2021 01:22:51 AM UTC, comment #8: 

comment #7:

>
> comment #6:
> > I like the explicit casting because it shows programmer intent.  Marking as "Patch Submitted".  Hopefully Michele can apply this patch and test compilation on a Solaris machine.


I don't know what happened to my previous comment.  It seems to have not made it.  Anyway, as I was trying to say I tried this patch and I can confirm that it does work in Solaris 10 SPARC on my Sun T4-1.  Thanks!

Michele <michele31415>
Thu 04 Mar 2021 01:18:39 AM UTC, comment #7: 

comment #6:

> I like the explicit casting because it shows programmer intent.  Marking as "Patch Submitted".  Hopefully Michele can apply this patch and test compilation on a Solaris machine.

Michele <michele31415>
Wed 03 Mar 2021 10:18:57 PM UTC, comment #6: 

I like the explicit casting because it shows programmer intent.  Marking as "Patch Submitted".  Hopefully Michele can apply this patch and test compilation on a Solaris machine.

Rik <rik5>
Project Administrator
Wed 03 Mar 2021 08:41:42 PM UTC, comment #5: 

We want to avoid including system header files (or gnulib replacements for them) in the wrapper header files because they may cause trouble when included directly in C++ source files.

Using the cast is fine as it explicitly shows the intent here, but I think conversion from any pointer type to void* should be allowed and OK without the cast in both C and C++.

John W. Eaton <jwe>
Project Administrator
Wed 03 Mar 2021 07:13:32 PM UTC, comment #4: 

Hm. I thought the compiler would perform the cast implicitly.
But we could also make it explicit. See attached patch.

(file #50982)

Markus Mützel <mmuetzel>
Project Member
Wed 03 Mar 2021 06:21:06 PM UTC, comment #3: 

It shouldn't compile.  The output of the function iconv_open is iconv_t.  One probably needs an explicit cast to pointer to void before the return statement.

 octave_iconv_open_wrapper (const char *tocode, const char *fromcode)
{
   return iconv_open (tocode, fromcode);
}

Rik <rik5>
Project Administrator
Wed 03 Mar 2021 05:48:02 PM UTC, comment #2: 

Does the attached patch also work to solve the issue on Solaris?

(file #50981)

Markus Mützel <mmuetzel>
Project Member
Wed 03 Mar 2021 05:29:57 PM UTC, comment #1: 

The issue is that iconv-wrappers.c #includes "iconv.h" while iconv-wrappers.h does not.

In iconv-wrappers.c, because it has included the iconv.h header file it can make use of the iconv_t definition which is a typedef.  On Linux systems, the definition in /usr/include/iconv.h is

typedef void *iconv_t;

which is a pointer to void.

Hence, in iconv-wrapers.h it is okay to directly write

void *

where one wants iconv_t.

Apparently Solaris defines iconv_t to a different value.

I'm adding jwe to the CC list as he knows more about why these wrappers are written the way they are.

Possible solution #1

Add '#include "iconv.h"' to the file iconv-wrapper.h and then use iconv_t to define functions.

This seems cleanest, but maybe there is a reason not to expose system header files?  On the other hand, several of the header files in the liboctave/wrappers directory use '#include <sys/types.h>'.

Possible solution #2

Use #ifdef based on OS (Solaris vs. NOT Solaris) in iconv-wrapper.h to choose between using a pointer to void or the data type used on Solaris for iconv_t.

Rik <rik5>
Project Administrator
Wed 03 Mar 2021 04:43:44 PM UTC, original submission:  

While building 6.2.0 on Solaris 10 SPARC with gcc 7.3.0, gmake ends thusly:

    liboctave/wrappers/iconv-wrappers.c:35:1: error: conflicting types for 'octave_iconv_open_wrapper'
     octave_iconv_open_wrapper (const char tocode, const char fromcode)
     ^~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from liboctave/wrappers/iconv-wrappers.c:32:0:
    liboctave/wrappers/iconv-wrappers.h:34:1: note: previous declaration of 'octave_iconv_open_wrapper' was here
     octave_iconv_open_wrapper (const char tocode, const char fromcode);
     ^~~~~~~~~~~~~~~~~~~~~~~~~
    liboctave/wrappers/iconv-wrappers.c:41:1: error: conflicting types for 'octave_iconv_close_wrapper'
     octave_iconv_close_wrapper (iconv_t cd)
     ^~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from liboctave/wrappers/iconv-wrappers.c:32:0:
    liboctave/wrappers/iconv-wrappers.h:37:1: note: previous declaration of 'octave_iconv_close_wrapper' was here
     octave_iconv_close_wrapper (void *cd);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~

The first error message is confusing because the declaration was split over two lines so the error output only showed the second lines (which are identical). In the first error the function is declared “extern void *” in the .h file and “iconv_t” in the c file. Which one is right?

Michele <michele31415>

 

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

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by michele31415 (Submitted the item)
  • -email is unavailable- added by michele31415
  •  

    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 project members can vote.

     

     

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-03-04 mmuetzel StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
    2021-03-03 rik5 StatusConfirmed => Patch Submitted
    2021-03-03 mmuetzel Attached File- => Added bug60162_iconv-wrappers-v2.patch, #50982
    2021-03-03 mmuetzel Attached File- => Added bug60162_iconv-wrappers.patch, #50981
    2021-03-03 rik5 StatusNone => Confirmed
    2021-03-03 rik5 Carbon-Copy- => Added jwe
    2021-03-03 michele31415 Carbon-Copy- => Added mdenber@gmx.com

    Back to the top


    Powered by Savane 3.7