Problem with has_bits on 64 bit Windows only

157 views
Skip to first unread message

Jim Hunziker

unread,
Feb 17, 2012, 10:17:26 AM2/17/12
to Protocol Buffers
I'm compiling a .proto file in both 64 bit windows and in 64 bit linux
(with version 2.4.1 of protobuf). The resulting .pb.h file is fine in
Linux, but the Windows 7 X64 version is very broken with respect to
has_bits. The problem only occurs when two bytes of has_bits are
required for tags.

.proto file:

message Foo {
required int32 a1 = 1;
required int32 a2 = 2;
required int32 a3 = 3;
required int32 a4 = 4;
required int32 a5 = 5;
required int32 a6 = 6;
required int32 a7 = 7;
required int32 a8 = 8;
required int32 a9 = 9;
required int32 a10 = 10;
required int32 a11 = 11;
required int32 a12 = 12;
required int32 a13 = 13;
required int32 a14 = 14;
required int32 a15 = 15;
required int32 a16 = 16;
required int32 a17 = 17;
required int32 a18 = 18;
required int32 a19 = 19;
required int32 a20 = 20;
required int32 a21 = 21;
required int32 a22 = 22;
required int32 a23 = 23;
required int32 a24 = 24;
required int32 a25 = 25;
required int32 a26 = 26;
required int32 a27 = 27;
required int32 a28 = 28;
required int32 a29 = 29;
required int32 a31 = 31;
required int32 a32 = 32;
required int32 a33 = 33;
required int32 a34 = 34;
}

relevant part of test.pb.h in Linux (looks correct):

// required int32 a24 = 24;
inline bool Foo::has_a24() const {
return (_has_bits_[0] & 0x00800000u) != 0;
}
inline void Foo::set_has_a24() {
_has_bits_[0] |= 0x00800000u;
}
inline void Foo::clear_has_a24() {
_has_bits_[0] &= ~0x00800000u;
}
inline void Foo::clear_a24() {
a24_ = 0;
clear_has_a24();
}
inline ::google::protobuf::int32 Foo::a24() const {
return a24_;
}
inline void Foo::set_a24(::google::protobuf::int32 value) {
set_has_a24();
a24_ = value;
}

// required int32 a25 = 25;
inline bool Foo::has_a25() const {
return (_has_bits_[0] & 0x01000000u) != 0;
}
inline void Foo::set_has_a25() {
_has_bits_[0] |= 0x01000000u;
}
inline void Foo::clear_has_a25() {
_has_bits_[0] &= ~0x01000000u;
}
inline void Foo::clear_a25() {
a25_ = 0;
clear_has_a25();
}
inline ::google::protobuf::int32 Foo::a25() const {
return a25_;
}
inline void Foo::set_a25(::google::protobuf::int32 value) {
set_has_a25();
a25_ = value;
}


relevant part of test.pb.h in Windows 7 X64 (broken! look at the masks
for a25):

// required int32 a24 = 24;
inline bool Foo::has_a24() const {
return (_has_bits_[0] & 0x00800000u) != 0;
}
inline void Foo::set_has_a24() {
_has_bits_[0] |= 0x00800000u;
}
inline void Foo::clear_has_a24() {
_has_bits_[0] &= ~0x00800000u;
}
inline void Foo::clear_a24() {
a24_ = 0;
clear_has_a24();
}
inline ::google::protobuf::int32 Foo::a24() const {
return a24_;
}
inline void Foo::set_a24(::google::protobuf::int32 value) {
set_has_a24();
a24_ = value;
}

// required int32 a25 = 25;
inline bool Foo::has_a25() const {
return (_has_bits_[0] & 0x11000000u) != 0;
}
inline void Foo::set_has_a25() {
_has_bits_[0] |= 0x11000000u;
}
inline void Foo::clear_has_a25() {
_has_bits_[0] &= ~0x11000000u;
}
inline void Foo::clear_a25() {
a25_ = 0;
clear_has_a25();
}
inline ::google::protobuf::int32 Foo::a25() const {
return a25_;
}
inline void Foo::set_a25(::google::protobuf::int32 value) {
set_has_a25();
a25_ = value;
}

sjd

unread,
Mar 12, 2012, 1:45:49 AM3/12/12
to Protocol Buffers
I've seen this too. Similar problem with has_bits, though I often
find that the (incorrectly generated) bit-mask is 0x00000000u.

Has anyone debugged this yet to determine the fix?

Regards,

Sean

On Feb 17, 8:17 am, Jim Hunziker <landt...@gmail.com> wrote:
> I'm compiling a .proto file in both64bitwindowsand in64bit linux
> (with version 2.4.1 of protobuf). The resulting .pb.h file is fine in
> Linux, but theWindows7 X64 version is very broken with respect to
> relevant part of test.pb.h inWindows7 X64 (broken! look at the masks
Reply all
Reply to author
Forward
0 new messages