Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006291OCamlOCaml generalpublic2014-01-09 14:102014-08-18 20:41
Reporterprotz 
Assigned Toprotz 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version4.02.0+dev 
Target Version4.03.0+devFixed in Version 
Summary0006291: Add a new warning for suspicious octal constants
DescriptionFollowing the comments from http://roscidus.com/blog/blog/2014/01/07/ocaml-the-bugs-so-far/, [^] I implemented a new warning that is triggered by decimal constants of the form "0n..." where n <> 0.

jonathan@ramona:~/Code/ocaml (trunk) $ cat /tmp/test.ml 
let x = 0123;;
let y = 123;;
jonathan@ramona:~/Code/ocaml (trunk) $ /usr/local/bin/ocaml -warn-error /tmp/test.ml
File "/tmp/test.ml", line 1, characters 8-12:
Warning 48: 0123 looks like you wrote an octal constant.
 Did you mean 0o123?


Damien, somehow I can't turn the warning off with -warn-error -48, and +48 seems to make it fatal. Am I missing something?
Tagspatch
Attached Filespatch file icon 0001-Warn-about-suspicious-decimal-constants.patch [^] (3,989 bytes) 2014-01-09 14:10 [Show Content]

- Relationships

-  Notes
(0010783)
protz (manager)
2014-01-09 14:12

I forgot to mention that the patch adds documentation in the man page for warnings 46 and 47 while we're at it. I know who implemented these warnings but I won't blame them in public ;-).
(0010784)
yallop (developer)
2014-01-09 14:37

Why is there a warning for 0700 but not for 0070?
(0010785)
protz (manager)
2014-01-09 14:50

I somehow suspected that if people are padding with more than one zero, they probably don't "mean" octal, but that's just a wild guess. I can warn for any leading zeroes if that sounds better.
(0010809)
doligez (administrator)
2014-01-17 18:03

I think it's better to warn for all leading zeroes. Easier to document, too.

To disable warning 48, you should use -w -48, not -warn-error.

- Issue History
Date Modified Username Field Change
2014-01-09 14:10 protz New Issue
2014-01-09 14:10 protz Status new => assigned
2014-01-09 14:10 protz Assigned To => protz
2014-01-09 14:10 protz File Added: 0001-Warn-about-suspicious-decimal-constants.patch
2014-01-09 14:10 protz Description Updated View Revisions
2014-01-09 14:12 protz Note Added: 0010783
2014-01-09 14:37 yallop Note Added: 0010784
2014-01-09 14:50 protz Note Added: 0010785
2014-01-17 18:03 doligez Note Added: 0010809
2014-01-17 18:03 doligez Tag Attached: patch
2014-08-18 20:41 doligez Target Version 4.02.0+dev => 4.03.0+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker