Opened 14 years ago

Closed 14 years ago

#2270 closed Patches (fixed)

Compile Warning: Assignment Operator Could not be generated

Reported by: Ryan Mulder <rjmyst3@…> Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.37.0 Severity: Problem
Keywords: Cc:

Description

Visual Studio 2005 warning #4512: "assignment operator could not be generated" is spawned during compile when including array.hpp and extended_type_info.hpp.

The attached patch declares a private assignment operator in the "array" and "extended_type_info" classes.

Attachments (1)

assignment_operator_warning.patch (731 bytes ) - added by Ryan Mulder <rjmyst3@…> 14 years ago.

Download all attachments as: .zip

Change History (6)

by Ryan Mulder <rjmyst3@…>, 14 years ago

comment:1 by Robert Ramey, 14 years ago

Resolution: wontfix
Status: newclosed

Instances of neither one of these classes should be assigned or copy constructed. An attempt to do so would be a serious error. As things are now, any attempt to assign or copy an instance of either of these classes would result in a compile-time error- which is what we want. Including this "fix" would permit the compilation to succeed and produce a program which would fail in subtle ways.

Robert Ramey

comment:2 by Ryan Mulder <rjmyst3@…>, 14 years ago

Milestone: Boost 1.37.0To Be Determined
Resolution: wontfix
Status: closedreopened
Version: Boost 1.36.0Boost 1.37.0

Robert,

Thanks for looking at this. I didn't reply to your comment 4 months ago, because I assumed you'd silence the warning in a different manner.

As the warning from extended_type_info.hpp is still spawned during compilation, I urge you to reconsider this patch.

I understand the design intent is to not allow copying the class. If you look closely at the patch, you'll see that the assignment operator is only declared, not defined. It is also in the private scope of the class.

This will make your intent to prevent copying clear both to the compiler and the programmer, while still producing a compile-time error on an attempt to assign an instance of the class.

Ryan Mulder

comment:3 by Robert Ramey, 14 years ago

OK, I've updated extended_type_info to make it non-copyable.

But review array.hpp. I contains make_array which returns a copy of an array wrapper and make_array is in fact used by the system and tests. That is, array must be copyable. I can't explain why this generates a warning. Perhaps array should contain an explicit copy/assignment constructors but I don't see why that should be necessary.

Take another look at array.

Robert Ramey

comment:4 by Ryan Mulder <rjmyst3@…>, 14 years ago

Thank you for updating extended_type_info.

I posted this patch against 1.36; as of 1.37, I do not see warnings from array. I think this issue is resolved.

Thanks very much for you help.

comment:5 by Robert Ramey, 14 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.