Modify

Opened 6 years ago

Closed 3 years ago

#6147 closed Bugs (fixed)

message_queue sample fails to compile in 32-bit

Reported by: Graham Perks <graham@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.56.0 Severity: Regression
Keywords: Cc: darthpjb@…

Description

Just upgraded to 1.48.

On OS X I compile the sample program with: gcc -I <blah path to boost>/include -arch i386 main.cpp

and it fails with "....boost/interprocess/ipc/message_queue.hpp:330: error: no matching function for call to ‘get_rounded_size(long unsigned int, const unsigned int&)’"

It's the MQ creation line that fails. If I build for x64, it compiles successfully. The source is:

#define BOOST_DATE_TIME_NO_LIB #include <boost/interprocess/ipc/message_queue.hpp> #include <iostream> #include <vector>

using namespace boost::interprocess;

int main () {

try{

Erase previous message queue message_queue::remove("message_queue");

Create a message_queue. message_queue mq (create_only only create

,"message_queue" name ,100 max message number ,sizeof(int) max message size );

Send 100 numbers for(int i = 0; i < 100; ++i){

mq.send(&i, sizeof(i), 0);

}

} catch(interprocess_exception &ex){

std::cout << ex.what() << std::endl; return 1;

}

return 0;

}

Attachments (0)

Change History (15)

comment:1 Changed 6 years ago by Graham Perks <graham@…>

Retry code formatting. It's the sample from the boost docs.

#define BOOST_DATE_TIME_NO_LIB
#include <boost/interprocess/ipc/message_queue.hpp>
#include <iostream>
#include <vector>

using namespace boost::interprocess;

int main ()
{
    try{
        //Erase previous message queue
        message_queue::remove("message_queue");
        
        //Create a message_queue.
        message_queue mq
        (create_only               //only create
         ,"message_queue"           //name
         ,100                       //max message number
         ,sizeof(int)               //max message size
         );
        
        //Send 100 numbers
        for(int i = 0; i < 100; ++i){
            mq.send(&i, sizeof(i), 0);
        }
    }
    catch(interprocess_exception &ex){
        std::cout << ex.what() << std::endl;
        return 1;
    }
    
    return 0;
}

comment:2 Changed 6 years ago by Graham Perks <graham@…>

If anyone has a workaround for this, it would be much appreciated.

comment:3 Changed 6 years ago by Graham Perks <graham@…>

I was able to workaround this by adding this code before including the boost headers. It adds a second type to the get_rounded_size template.

namespace boost {
    namespace interprocess { 
        namespace ipcdetail {
            
            //Rounds "orig_size" by excess to round_to bytes
            template<class SizeType, class ST2>
            inline SizeType get_rounded_size(SizeType orig_size, ST2 round_to)
            {
                return ((orig_size-1)/round_to+1)*round_to;
            }
        }
    }
}

comment:4 Changed 6 years ago by Ion Gaztañaga

Resolution: fixed
Status: newclosed

Fixed in trunk and release branches adding

#include <boost/interprocess/detail/utilities.hpp>

to message queue header.

comment:5 Changed 5 years ago by moala@…

Resolution: fixed
Status: closedreopened
Version: Boost 1.48.0Boost 1.50.0

Still not fixed in i386 GCC 4.2 xcode 3.2.6 (only works in x86_64) even with this

#include <boost/interprocess/detail/utilities.hpp>

inclusion in message_queue.hpp in boost 1.50 (macports) (with Mac OS X 10.6 SDK / deployment target 10.5).

Graham Perks's workaround allows compiling.

comment:6 Changed 5 years ago by Ion Gaztañaga

I successfully compiled your test using trunk code in Mac OS 10.6.2 with GCC:

i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)

can you check the bug is fixed?

comment:7 Changed 4 years ago by Ion Gaztañaga

Resolution: worksforme
Status: reopenedclosed

No news from the reporter so I'm closing the issue.

comment:8 Changed 3 years ago by darthpjb@…

Resolution: worksforme
Status: closedreopened

I can confirm that this issue is still relevant (as mentioned by moala) in boost 1_56_0.

32bit Intel builds for 10.7.5 fail as above on LLVM GCC 4.2 - The mentioned workaround did indeed solve the problem for me also.

Note that I am static-linking boost, and forcing the compiler to GNU99 dialect. These may be related?

If needed I may be able to create a reproducing project.

comment:9 Changed 3 years ago by darthpjb@…

I can now further confirm the issue is also apparent on I386 builds using LLVM GCC 5.1, for the 10.9 SDK, Xcode 5.1.1.

It would seem this does actively apply to the most recent LLVM compilers, across the full range of Mac OSX builds. As long as the target architecture is 32bit.

comment:10 Changed 3 years ago by darthpjb@…

Further Confirmation: The issue is also present on OSX 10.5.8, Xcode 3.1.4, Using Apple GCC 4.0

Graham Perk's fix does, once again, solve the issue.

comment:11 Changed 3 years ago by anonymous

Version: Boost 1.50.0Boost 1.56.0

comment:12 Changed 3 years ago by darthpjb@…

Cc: darthpjb@… added

comment:13 Changed 3 years ago by Ion Gaztañaga

Without access to the platform, I can't know where the problem lies. However, one alternative could be specifying the template type in get_rounded_size. That is:

replace "get_rounded_size(a, b)" calls with "get_rounded_size<size_type>(a, b)".

Please let me know if this fixes the problem

Last edited 3 years ago by Ion Gaztañaga (previous) (diff)

comment:14 Changed 3 years ago by bbaldino@…

For what it's worth, I had this same problem on OSX (with boost 1.56) and this workaround got things compiling.

comment:15 Changed 3 years ago by Ion Gaztañaga

Resolution: fixed
Status: reopenedclosed

Fixed in Boost 1.57 Beta.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ion Gaztañaga.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.