You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Gordon Sim (JIRA)" <ji...@apache.org> on 2011/04/13 12:14:05 UTC

[jira] [Created] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Variant converts from negative number in string format to unsigned integer without error
----------------------------------------------------------------------------------------

                 Key: QPID-3206
                 URL: https://issues.apache.org/jira/browse/QPID-3206
             Project: Qpid
          Issue Type: Bug
          Components: C++ Broker, C++ Client
    Affects Versions: 0.8, 0.10
            Reporter: Gordon Sim
            Assignee: Gordon Sim
             Fix For: 0.11


E.g. 
  uint16_t i = 0;
  qpid::types::Variant v = "-5";
  i = v;

The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).

See e.g:
http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019838#comment-13019838 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review460
-----------------------------------------------------------

Ship it!


- Alan


On 2011-04-13 17:53:50, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 17:53:50)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019358#comment-13019358 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review444
-----------------------------------------------------------



/trunk/qpid/cpp/src/qpid/types/Variant.cpp
<https://reviews.apache.org/r/596/#comment866>

    I think this test will do the wrong thing for -0.
    
    It's an annoying corner case but it does have a correct unsigned representation!



/trunk/qpid/cpp/src/qpid/types/Variant.cpp
<https://reviews.apache.org/r/596/#comment867>

    I think you need a comment to explain that an exception will be thrown below, so that someone modifying this code won't lose the thrown exception.


- Andrew


On 2011-04-13 13:00:09, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 13:00:09)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019407#comment-13019407 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/
-----------------------------------------------------------

(Updated 2011-04-13 16:13:56.238125)


Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.


Changes
-------

Added new tests. Fixed special case of -0.


Summary
-------

Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)


This addresses bug QPID-3206.
    https://issues.apache.org/jira/browse/QPID-3206


Diffs (updated)
-----

  /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
  /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 

Diff: https://reviews.apache.org/r/596/diff


Testing
-------

New tests included in patch


Thanks,

Gordon



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019305#comment-13019305 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------



bq.  On 2011-04-13 12:43:57, Ted Ross wrote:
bq.  > /trunk/qpid/cpp/src/qpid/types/Variant.cpp, line 114
bq.  > <https://reviews.apache.org/r/596/diff/1/?file=15701#file15701line114>
bq.  >
bq.  >     This change is based on the assumption that convertFromString is only called for numeric types of T.  Does this do the right thing for floating point numbers?  Does is_signed always return true for floats and doubles?
bq.  >

Yes. it appears to do the right thing and I would certainly expect is_signed to always return true for floats/doubles. I've added another couple of test cases.


- Gordon


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review441
-----------------------------------------------------------


On 2011-04-13 13:00:09, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 13:00:09)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019433#comment-13019433 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review450
-----------------------------------------------------------

Ship it!


- Steve


On 2011-04-13 16:13:56, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 16:13:56)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019306#comment-13019306 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/
-----------------------------------------------------------

(Updated 2011-04-13 13:00:09.156587)


Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.


Changes
-------

Added test cases from string to float/double conversion when the value is negative.


Summary
-------

Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)


This addresses bug QPID-3206.
    https://issues.apache.org/jira/browse/QPID-3206


Diffs (updated)
-----

  /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
  /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 

Diff: https://reviews.apache.org/r/596/diff


Testing
-------

New tests included in patch


Thanks,

Gordon



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019297#comment-13019297 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review441
-----------------------------------------------------------



/trunk/qpid/cpp/src/qpid/types/Variant.cpp
<https://reviews.apache.org/r/596/#comment864>

    This change is based on the assumption that convertFromString is only called for numeric types of T.  Does this do the right thing for floating point numbers?  Does is_signed always return true for floats and doubles?
    


- Ted


On 2011-04-13 10:49:00, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 10:49:00)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019379#comment-13019379 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review447
-----------------------------------------------------------

Ship it!


I think the extra tests below would improve the test coverage a bit, but not essential.


/trunk/qpid/cpp/src/tests/Variant.cpp
<https://reviews.apache.org/r/596/#comment871>

    Some things we don't check here that should also fail (essentially values that are valid as uint but not int or negative numbers too large.
    
    maxint<int64_t>+1 in a string -> int64_t
    [should fail]
    minint<int64_t>-1 in a string -> int64_t
    [should fail]
    
    and for int32_t too
    
    


- Andrew


On 2011-04-13 15:11:45, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 15:11:45)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019406#comment-13019406 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------



bq.  On 2011-04-13 14:44:16, Andrew Stitcher wrote:
bq.  > /trunk/qpid/cpp/src/qpid/types/Variant.cpp, line 114
bq.  > <https://reviews.apache.org/r/596/diff/2/?file=15703#file15703line114>
bq.  >
bq.  >     I think this test will do the wrong thing for -0.
bq.  >     
bq.  >     It's an annoying corner case but it does have a correct unsigned representation!
bq.  
bq.  Gordon Sim wrote:
bq.      Interestingly -0 fails to convert to an unsigned int in the existing code on the older compilers.

Fixed now.


- Gordon


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review444
-----------------------------------------------------------


On 2011-04-13 16:13:56, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 16:13:56)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019408#comment-13019408 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------



bq.  On 2011-04-13 15:22:31, Andrew Stitcher wrote:
bq.  > /trunk/qpid/cpp/src/tests/Variant.cpp, line 109
bq.  > <https://reviews.apache.org/r/596/diff/3/?file=15706#file15706line109>
bq.  >
bq.  >     Some things we don't check here that should also fail (essentially values that are valid as uint but not int or negative numbers too large.
bq.  >     
bq.  >     maxint<int64_t>+1 in a string -> int64_t
bq.  >     [should fail]
bq.  >     minint<int64_t>-1 in a string -> int64_t
bq.  >     [should fail]
bq.  >     
bq.  >     and for int32_t too
bq.  >     
bq.  >

Added in latest patch.


- Gordon


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review447
-----------------------------------------------------------


On 2011-04-13 16:13:56, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 16:13:56)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019460#comment-13019460 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/
-----------------------------------------------------------

(Updated 2011-04-13 17:53:50.358454)


Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.


Changes
-------

Revise handling of negative zero to also catch -000 etc


Summary
-------

Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)


This addresses bug QPID-3206.
    https://issues.apache.org/jira/browse/QPID-3206


Diffs (updated)
-----

  /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
  /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 

Diff: https://reviews.apache.org/r/596/diff


Testing
-------

New tests included in patch


Thanks,

Gordon



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019372#comment-13019372 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/
-----------------------------------------------------------

(Updated 2011-04-13 15:11:45.041621)


Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.


Changes
-------

Added comment to clarify that flow of control leads to exception, as requested by Andrew.


Summary
-------

Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)


This addresses bug QPID-3206.
    https://issues.apache.org/jira/browse/QPID-3206


Diffs (updated)
-----

  /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
  /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 

Diff: https://reviews.apache.org/r/596/diff


Testing
-------

New tests included in patch


Thanks,

Gordon



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019331#comment-13019331 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review443
-----------------------------------------------------------

Ship it!


- Kenneth


On 2011-04-13 13:00:09, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 13:00:09)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019507#comment-13019507 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review456
-----------------------------------------------------------



/trunk/qpid/cpp/src/qpid/types/Variant.cpp
<https://reviews.apache.org/r/596/#comment883>

    good point.


- Andrew


On 2011-04-13 17:53:50, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 17:53:50)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019278#comment-13019278 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/
-----------------------------------------------------------

Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.


Summary
-------

Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)


This addresses bug QPID-3206.
    https://issues.apache.org/jira/browse/QPID-3206


Diffs
-----

  /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
  /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 

Diff: https://reviews.apache.org/r/596/diff


Testing
-------

New tests included in patch


Thanks,

Gordon



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019484#comment-13019484 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------



bq.  On 2011-04-13 18:17:31, Andrew Stitcher wrote:
bq.  > /trunk/qpid/cpp/src/qpid/types/Variant.cpp, line 37
bq.  > <https://reviews.apache.org/r/596/diff/5/?file=15709#file15709line37>
bq.  >
bq.  >     Don't need this constant now

Good catch, will remove.


bq.  On 2011-04-13 18:17:31, Andrew Stitcher wrote:
bq.  > /trunk/qpid/cpp/src/qpid/types/Variant.cpp, line 126
bq.  > <https://reviews.apache.org/r/596/diff/5/?file=15709#file15709line126>
bq.  >
bq.  >     Could still cast to T as it will be 0 if it is correct and any non zero value is an error in this branch.

You mean 'boost::lexical_cast<T>(*s)'? That will fail for -0 on older gcc compilers.


- Gordon


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review454
-----------------------------------------------------------


On 2011-04-13 17:53:50, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 17:53:50)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Resolved] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "Gordon Sim (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gordon Sim resolved QPID-3206.
------------------------------

    Resolution: Fixed

> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019374#comment-13019374 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------



bq.  On 2011-04-13 14:44:16, Andrew Stitcher wrote:
bq.  > /trunk/qpid/cpp/src/qpid/types/Variant.cpp, line 118
bq.  > <https://reviews.apache.org/r/596/diff/2/?file=15703#file15703line118>
bq.  >
bq.  >     I think you need a comment to explain that an exception will be thrown below, so that someone modifying this code won't lose the thrown exception.

Agreed. New patch uploaded that does so.


bq.  On 2011-04-13 14:44:16, Andrew Stitcher wrote:
bq.  > /trunk/qpid/cpp/src/qpid/types/Variant.cpp, line 114
bq.  > <https://reviews.apache.org/r/596/diff/2/?file=15703#file15703line114>
bq.  >
bq.  >     I think this test will do the wrong thing for -0.
bq.  >     
bq.  >     It's an annoying corner case but it does have a correct unsigned representation!

Interestingly -0 fails to convert to an unsigned int in the existing code on the older compilers.


- Gordon


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review444
-----------------------------------------------------------


On 2011-04-13 15:11:45, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 15:11:45)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019472#comment-13019472 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review454
-----------------------------------------------------------



/trunk/qpid/cpp/src/qpid/types/Variant.cpp
<https://reviews.apache.org/r/596/#comment879>

    Don't need this constant now



/trunk/qpid/cpp/src/qpid/types/Variant.cpp
<https://reviews.apache.org/r/596/#comment880>

    Could still cast to T as it will be 0 if it is correct and any non zero value is an error in this branch.


- Andrew


On 2011-04-13 17:53:50, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 17:53:50)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019450#comment-13019450 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review451
-----------------------------------------------------------


Another useful test would be to convert a float with a "-" not at the first position something like "12e-3" -> double or float.
[Just to be sure the find("-") doesn't kick in unexpectedly]


/trunk/qpid/cpp/src/qpid/types/Variant.cpp
<https://reviews.apache.org/r/596/#comment874>

    This won't allow the (stupid but) legal -00 or -000 etc!
    
    Perhaps a better test would be recording you saw a "-" and doing the conversion anyway, then only throwing if the result was non zero.
    
    something like:
    
    bool n = s->find('-') != 0;
    T r = boost::lexical_cast<T>(*s);
    if (n && r != 0) {
        throw InvalidConversion(...);
    }


- Andrew


On 2011-04-13 16:13:56, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 16:13:56)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "jiraposter@reviews.apache.org (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019452#comment-13019452 ] 

jiraposter@reviews.apache.org commented on QPID-3206:
-----------------------------------------------------



bq.  On 2011-04-13 14:44:16, Andrew Stitcher wrote:
bq.  > /trunk/qpid/cpp/src/qpid/types/Variant.cpp, line 114
bq.  > <https://reviews.apache.org/r/596/diff/2/?file=15703#file15703line114>
bq.  >
bq.  >     I think this test will do the wrong thing for -0.
bq.  >     
bq.  >     It's an annoying corner case but it does have a correct unsigned representation!
bq.  
bq.  Gordon Sim wrote:
bq.      Interestingly -0 fails to convert to an unsigned int in the existing code on the older compilers.
bq.  
bq.  Gordon Sim wrote:
bq.      Fixed now.

Ok then, I suppose it depends how finicky we want to be!


- Andrew


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/596/#review444
-----------------------------------------------------------


On 2011-04-13 16:13:56, Gordon Sim wrote:
bq.  
bq.  -----------------------------------------------------------
bq.  This is an automatically generated e-mail. To reply, visit:
bq.  https://reviews.apache.org/r/596/
bq.  -----------------------------------------------------------
bq.  
bq.  (Updated 2011-04-13 16:13:56)
bq.  
bq.  
bq.  Review request for Andrew Stitcher, Alan Conway, Kenneth Giusti, Ted Ross, and Steve Huston.
bq.  
bq.  
bq.  Summary
bq.  -------
bq.  
bq.  Add special test for negative numeric strings when converting to unsigned values. (It appears - though I could be wrong - that in basic form stringstream does not do any special handling of negatives for different locales. That appears only to be done for money values.)
bq.  
bq.  
bq.  This addresses bug QPID-3206.
bq.      https://issues.apache.org/jira/browse/QPID-3206
bq.  
bq.  
bq.  Diffs
bq.  -----
bq.  
bq.    /trunk/qpid/cpp/src/qpid/types/Variant.cpp 1090157 
bq.    /trunk/qpid/cpp/src/tests/Variant.cpp 1090157 
bq.  
bq.  Diff: https://reviews.apache.org/r/596/diff
bq.  
bq.  
bq.  Testing
bq.  -------
bq.  
bq.  New tests included in patch
bq.  
bq.  
bq.  Thanks,
bq.  
bq.  Gordon
bq.  
bq.



> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] [Commented] (QPID-3206) Variant converts from negative number in string format to unsigned integer without error

Posted by "Gordon Sim (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019276#comment-13019276 ] 

Gordon Sim commented on QPID-3206:
----------------------------------

Suggested change to retain behaviour of older gcc: https://reviews.apache.org/r/596/

> Variant converts from negative number in string format to unsigned integer without error
> ----------------------------------------------------------------------------------------
>
>                 Key: QPID-3206
>                 URL: https://issues.apache.org/jira/browse/QPID-3206
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker, C++ Client
>    Affects Versions: 0.8, 0.10
>            Reporter: Gordon Sim
>            Assignee: Gordon Sim
>             Fix For: 0.11
>
>
> E.g. 
>   uint16_t i = 0;
>   qpid::types::Variant v = "-5";
>   i = v;
> The above results in an exception in older versions of gcc (e.g. 4.1.2) but sets i to 65531 on later versions (e.g. 4.4.4). This is a result of a fix to the gcc std library to be compliant with specification which requires stringstream to accept negative values even for unsigned ints (which is the behaviour of scanf).
> See e.g:
> http://boost.2283326.n4.nabble.com/conversion-lexical-cast-doesn-t-throw-td2593967.html
> http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/97475b21515462c9/ce369a327fa39243#ce369a327fa39243

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org