------- Additional Comments From joseph at codesourcery dot com  2005-08-19 
17:28 -------
Subject: Re:  New: Implement binary constants with
 a "0b" prefix

The patch does not document how the types of binary constants are 
determined.  I suppose the rules are the same as for octal and hexadecimal 
constants, but the documentation needs to say so.

The patch does not document the 0B prefix, although the code accepts it.

The documentation should say @samp{0}, @samp{1}, @samp{0b}.

You can't write diagnostics like

+    SYNTAX_ERROR3 ("invalid digit \"%c\" in %s constant", '0' + max_digit,
+                  radix == 2? "binary": "octal");

because this doesn't work with i18n.  You need to have two separate 
strings, each of them a complete sentence, rather than building up 
sentences from fragments.  If you use a conditional expression, check 
whether you need to mark the strings with N_ to get them in cpplib.pot.

It's not clear how you ensure that someone can't write floating point 
numbers as e.g. 0b1e2 (the check for floats says in part "radix <= 10 && 
(c == 'e' || c == 'E')" which would allow binary, being designed to allow 
8 (0123e4 being decimal but looking like octal at first) and 10).

The patch is missing testcases.  They should include that the values of 
these constants (both 0b and 0B) are correct (both in the compiler and in 
preprocessor conditionals), that the types follow the correct rules (which 
need to be documented; see c99-intconst-1.c for how to test constant type 
rules), that you can't write floating point numbers such as 0b1e2 or 
0b1p3, and that these constants receive warnings with -pedantic and errors 
with -pedantic-errors (for both C and C++, and for both the compiler and 
the preprocessor).

If you don't already have a copyright assignment on file you may need to 
get one.  See <http://gcc.gnu.org/contribute.html>.  As new features can't 
go in until 4.1 has branched there should be plenty of time to do so 
before a complete patch (submitted to gcc-patches) can be considered.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23479

Reply via email to