#230: Inplace arithmetic operators do not guaranty that the type of the target
can hold the results
------------------------+---------------------------------------------------
Reporter: jacquelet | Owner: Olena Team
Type: defect | Status: new
Priority: major | Milestone: Olena 1.1
Component: Milena | Version: 1.0
Resolution: | Keywords:
------------------------+---------------------------------------------------
Description changed by lazzara:
Old description:
#include <mln/core/image/image2d.hh>
#include <mln/arith/times.hh>
#include <mln/arith/minus.hh>
#include <mln/value/int_u8.hh>
int main()
{
using namespace mln;
typedef mln::value::int_u8 t_int_u8;
typedef mln::image2d<t_int_u8> t_img;
typedef mln_trait_op_minus_(t_img,t_img) t_minus;
typedef mln_trait_op_times_(t_minus,t_minus) t_times;
t_img img1;
t_img img2;
t_img img3;
t_minus minus;
t_times times;
// Loading images ...
img3 = img1 - img2; // Does not compile as expected because img1 -
img2 is of type t_minus.
minus = img1 - img2; // Compile as expected.
img3 = minus * minus; // Does not compile as expected because img1 *
img2 is of type t_times
times = minus * minus; // Compile as expected.
// But ...
img3 *= (minus - minus); // Compile... But should not! Inplace
// operators do not guaranty that the type of
// the target can hold the results (in term of
// range).
}
New description:
{{{
#include <mln/core/image/image2d.hh>
#include <mln/arith/times.hh>
#include <mln/arith/minus.hh>
#include <mln/value/int_u8.hh>
int main()
{
using namespace mln;
typedef mln::value::int_u8 t_int_u8;
typedef mln::image2d<t_int_u8> t_img;
typedef mln_trait_op_minus_(t_img,t_img) t_minus;
typedef mln_trait_op_times_(t_minus,t_minus) t_times;
t_img img1;
t_img img2;
t_img img3;
t_minus minus;
t_times times;
// Loading images ...
img3 = img1 - img2; // Does not compile as expected because img1 -
img2 is of type t_minus.
minus = img1 - img2; // Compile as expected.
img3 = minus * minus; // Does not compile as expected because img1 *
img2 is of type t_times
times = minus * minus; // Compile as expected.
// But ...
img3 *= (minus - minus); // Compile... But should not! Inplace
// operators do not guaranty that the type of
// the target can hold the results (in term of
// range).
}
}}}
--
--
Ticket URL: <https://trac.lrde.org/olena/ticket/230#comment:1>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.