Saturday, August 29, 2009

comp.lang.c++ - 25 new messages in 13 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* Weird warning about data type range - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/c0fda54bd4ba1f60?hl=en
* "might be used uninitialized..." what? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/b8f946d469d552ff?hl=en
* An access issue -- programming on auto-pilot... - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/660a8f377649dc9b?hl=en
* Advanced C struct programming : data structure design and implementation in
C / John W.L. Ogilvie - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/dd65b1534dd45d72?hl=en
* Can anyone write this recursion for simple regexp more beautifully and
clearly than the braggarts - 5 messages, 5 authors
http://groups.google.com/group/comp.lang.c++/t/af69810e4522c696?hl=en
* ∪ω∪2009 NEW HOT SALE!!! Cheap wholesale NFL Jerseys: *09 Super Bowl* *09 Pro
Bowl* *Baltimore Ravens* *Carolina Panthers* ect at website: www.fjrjtrade.com
(paypal payment) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/a4d2d377092cf262?hl=en
* Selection algorithm - 6 messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/4d4bcabfc0f41d26?hl=en
* 。◕‿◕。China cheap prcie discount Nike Shox NZ, Nike Jordan shoes, Nike Air
Max shoes ect at Website: www.fjrjtrade.com (paypal payment) - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/a48dd069a793d514?hl=en
* ※_※_※wholesale cheap Jeans at www.salewto.com - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/e581e05bf88fe97c?hl=en
* ╃♡╃♡╃ Wholesale Fashion Jeans Prada,RMC,G-star,Cavalli,Iceberg,Levis,Coogi,
BBC,Laguna,True Religion Jeans www.aoatrade.com - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/d941706df24ba7db?hl=en
* ๑۩♡๑۩Hot sale Fashion Nike Jordan,shox,free,rift,max,AF1,Bape,Gucci,Prada,
shoes Wholesale and retail "Welcome to www.aoatrade.com" - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/d15c7d771794f1a5?hl=en
* ♡*-*♡Wholesale Apple mobile phones, Iphone 3G 16gb&8gb,Iphone3Gs,M89,M88,T32,
G1,G2,TV Brand new,unlocked,with all accessories Fashion - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/5e78f41523fc8b60?hl=en
* ◆⊙◆Website: WWW.FJRJTRADE.COM 2009 cheap price wholesale fashion True Relig
Jeans with high quality (paypal payment) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/b75d38b9ffceefd6?hl=en

==============================================================================
TOPIC: Weird warning about data type range
http://groups.google.com/group/comp.lang.c++/t/c0fda54bd4ba1f60?hl=en
==============================================================================

== 1 of 3 ==
Date: Sat, Aug 29 2009 5:12 am
From: Stuart Golodetz


SG wrote:
> On 29 Aug., 13:20, Stuart Golodetz <b...@blah.com> wrote:
>> Note it doesn't say anything about the entire if condition, just about a
>> particular comparison (specifically the c <= 127 one). It would seem
>> that char is signed by default on your platform. To get rid of the
>> warning, just delete the second comparison, i.e. change to using:
>>
>> if(c >= 110)
>
> That's not really satisfactory if you want your code to be portable
> and support CHAR_MAX>127 cases. I'm not really interested in whether
> the compiler figured out that it can ignore the c<=127 test because
> the standard doesn't guarantee CHAR_MAX to be 127. CHAR_MAX can be
> larger.
>
> I do appreciate warnings, though. A warning in cases like
>
> unsigned foo = getfoo();
> if (foo>=0) {
> // ...
> }
>
> is totally fine because foo can never be negative regardless of the
> implementation details.
>
> Cheers!
> SG

True enough. I guess we'd need to know more about the intent of the code
to write a portable version in this instance though (e.g. I can easily
make it work just by changing char c to int c, but that's not really
answering the original question). My guess intent-wise here is "test
program", but I may be wrong :-)

Cheers,
Stu


== 2 of 3 ==
Date: Sat, Aug 29 2009 7:14 am
From: Jonathan Lee


On Aug 29, 3:33 am, Digital Puer <digital_p...@hotmail.com> wrote:
> Line 7 is the comparison "c <= 127". Ok fine, that will always
> be true, but the entire if-expression may not be true since
> there is && in the expression.

Why not just #include <climits> and wrap the second half in an #if?

if (c >= 110
#if (CHAR_MAX > 127)
&& c <= 127

No comments: