digitalmars.D - Warnings about potential loss of data
- Derek Parnell (32/32) Feb 06 2006 Assuming that the idea behind the "-w" switch is to help coders locate t...
- Sean Kelly (4/8) Feb 06 2006 Agreed. I'd like the compiler to warn me about narrowing conversions
- Matthew (4/11) Feb 06 2006 the
- Stewart Gordon (15/29) Feb 07 2006 What is an "optional error"? Either a piece of code is legal, or it
- U.Baumanis (4/20) Feb 07 2006 Yep this is error - some rocket can fall down because of this!
- Derek Parnell (7/15) Feb 07 2006 It was from something that Walter said about "-w" warnings ...
- Don Clugston (4/24) Feb 07 2006 "pedantic errors" might be a better term.
Assuming that the idea behind the "-w" switch is to help coders locate the assumptions that the compiler is making on our behalf, I think that it would be useful to add an "optional error" when the compiler detects a potential loss of data. Example 1: import std.stdio; void main() { uint a; int b; b = -3; a = b; // A warning here would be appreciated. writefln("a = ", a, ", b = ", b); // result: a = 4294967293, b = -3 } Example 2: void Foo() { int a; long b; b = SomeFunction(); a = b; // A warning here would be appreciated. } and there are many other examples too. -- Derek (skype: derek.j.parnell) Melbourne, Australia "Down with mediocracy!" 7/02/2006 11:16:27 AM
Feb 06 2006
Derek Parnell wrote:Assuming that the idea behind the "-w" switch is to help coders locate the assumptions that the compiler is making on our behalf, I think that it would be useful to add an "optional error" when the compiler detects a potential loss of data.Agreed. I'd like the compiler to warn me about narrowing conversions that don't use an explicit cast. Sean
Feb 06 2006
"Sean Kelly" <sean f4.ca> wrote in message news:ds8pmm$ups$1 digitaldaemon.com...Derek Parnell wrote:theAssuming that the idea behind the "-w" switch is to help coders locateWistfully ROFL!assumptions that the compiler is making on our behalf, I think that it would be useful to add an "optional error" when the compiler detects a potential loss of data.Agreed. I'd like the compiler to warn me about narrowing conversions that don't use an explicit cast.
Feb 06 2006
Derek Parnell wrote:Assuming that the idea behind the "-w" switch is to help coders locate the assumptions that the compiler is making on our behalf, I think that it would be useful to add an "optional error" when the compiler detects a potential loss of data.What is an "optional error"? Either a piece of code is legal, or it isn't, surely? <snip>Example 2: void Foo() { int a; long b; b = SomeFunction(); a = b; // A warning here would be appreciated. }<snip> I'd like this to be an error. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Feb 07 2006
In article <dsa2nv$1v8q$1 digitaldaemon.com>, Stewart Gordon says...What is an "optional error"? Either a piece of code is legal, or it isn't, surely? <snip>Yep this is error - some rocket can fall down because of this! -- UBExample 2: void Foo() { int a; long b; b = SomeFunction(); a = b; // A warning here would be appreciated. }<snip> I'd like this to be an error. Stewart.
Feb 07 2006
On Tue, 07 Feb 2006 23:10:39 +1100, Stewart Gordon <smjg_1998 yahoo.com> wrote:Derek Parnell wrote:It was from something that Walter said about "-w" warnings ... 'Think of them as "optional errors" instead of warnings <g>.' - Walter -- Derek Parnell Melbourne, AustraliaAssuming that the idea behind the "-w" switch is to help coders locate the assumptions that the compiler is making on our behalf, I think that it would be useful to add an "optional error" when the compiler detects a potential loss of data.What is an "optional error"? Either a piece of code is legal, or it isn't, surely?
Feb 07 2006
Derek Parnell wrote:On Tue, 07 Feb 2006 23:10:39 +1100, Stewart Gordon <smjg_1998 yahoo.com> wrote:"pedantic errors" might be a better term. I think that what you're doing is telling the compiler something about your coding style (and perhaps, what kinds of bugs you create).Derek Parnell wrote:It was from something that Walter said about "-w" warnings ... 'Think of them as "optional errors" instead of warnings <g>.' - WalterAssuming that the idea behind the "-w" switch is to help coders locate the assumptions that the compiler is making on our behalf, I think that it would be useful to add an "optional error" when the compiler detects a potential loss of data.What is an "optional error"? Either a piece of code is legal, or it isn't, surely?
Feb 07 2006