<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Advogato blog for jsm28</title>
    <link>http://www.advogato.org/person/jsm28/</link>
    <description>Advogato blog for jsm28</description>
    <language>en-us</language>
    <generator>mod_virgule</generator>
    <pubDate>Wed, 19 Jun 2013 23:27:17 GMT</pubDate>
    <item>
      <pubDate>Fri, 7 Sep 2001 20:54:49 GMT</pubDate>
      <title>7 Sep 2001</title>
      <link>http://www.advogato.org/person/jsm28/diary.html?start=4</link>
      <guid>http://www.advogato.org/person/jsm28/diary.html?start=4</guid>
      <description>&lt;p&gt;I went to today's UK C panel (BSI IST/5/-/14) meeting.
We now have panel positions on the direction work on C
ought to be going for now and the &lt;a href="http://wwwold.dkuug.dk/jtc1/sc22/open/n3269.pdf" &gt;proposed
embedded C TR&lt;/a&gt;.  Most of Clive Feather's proposed
Defect Reports (some arising from issues I noticed while
working on GCC) will be forwarded to &lt;a href="http://wwwold.dkuug.dk/JTC1/SC22/WG14/" &gt;WG14&lt;/a&gt;.</description>
    </item>
    <item>
      <pubDate>Thu, 7 Dec 2000 13:06:44 GMT</pubDate>
      <title>7 Dec 2000</title>
      <link>http://www.advogato.org/person/jsm28/diary.html?start=3</link>
      <guid>http://www.advogato.org/person/jsm28/diary.html?start=3</guid>
      <description>&lt;p&gt;I've finally managed to get my patches for format
security warnings approved for &lt;a href="http://www.advogato.org/proj/GCC:%20GNU%20Compiler%20Collection/" &gt;GCC&lt;/a&gt;.
With current CVS GCC, you can now compile with
&lt;tt&gt;-Wall -Wformat-security -Wmissing-format-attribute&lt;/tt&gt;
and detect problems such as the klogd hole of a few months
ago; this will detect uses of the form &lt;tt&gt;printf (foo);&lt;/tt&gt;
where &lt;tt&gt;foo&lt;/tt&gt; is variable and so might contain &lt;tt&gt;%&lt;/tt&gt;.
(For best effect, you may need to add format attributes
to &lt;tt&gt;&amp;lt;sys/syslog.h&amp;gt;&lt;/tt&gt; for &lt;tt&gt;syslog&lt;/tt&gt;
and &lt;tt&gt;vsyslog&lt;/tt&gt;.)  Previous changes I made in October
mean it won't give spurious warnings for conditional expressions
(where all leaves are constant) or if the format string is
a &lt;tt&gt;const&lt;/tt&gt; array.</description>
    </item>
    <item>
      <pubDate>Mon, 18 Sep 2000 13:27:47 GMT</pubDate>
      <title>18 Sep 2000</title>
      <link>http://www.advogato.org/person/jsm28/diary.html?start=2</link>
      <guid>http://www.advogato.org/person/jsm28/diary.html?start=2</guid>
      <description>&lt;p&gt;I'm in the process of reorganising
&lt;a href="http://www.advogato.org/proj/GCC:%20GNU%20Compiler%20Collection/" &gt;GCC&lt;/a&gt;'s
code for checking &lt;tt&gt;printf&lt;/tt&gt;, &lt;tt&gt;scanf&lt;/tt&gt; and
&lt;tt&gt;strftime&lt;/tt&gt; formats.

&lt;p&gt; &lt;p&gt;Originally the code used a flag to indicate whether a
function was printf-like or scanf-like.  Then more and more
format features from X/Open, various extensions and C99 were
added, &lt;tt&gt;strftime&lt;/tt&gt; format support was added to help
detect Y2K problems, and the amount of ad hoc conditionals
in the code for particular cases steadily went up; though
the details of what type is expected by each combination
of a conversion specifier (e.g. &lt;tt&gt;d&lt;/tt&gt;) and a length
modifier (e.g. &lt;tt&gt;l&lt;/tt&gt;) were stored in a table (in this
example showing that &lt;tt&gt;printf&lt;/tt&gt; &lt;tt&gt;%ld&lt;/tt&gt; expects
a &lt;tt&gt;long&lt;/tt&gt; argument), as were details of the acceptable
flags on each conversion, more and more other information
went into ad hoc code, which was full of bugs, especially
in the details of what GCC accepted with each standard
version selected and &lt;tt&gt;-pedantic&lt;/tt&gt;.

&lt;p&gt; &lt;p&gt;After reorganising and rewriting much of the code, it
should now follow C99 correctly, except for lack of support
for the &lt;tt&gt;j&lt;/tt&gt; length modifier (&lt;tt&gt;intmax_t&lt;/tt&gt; and
&lt;tt&gt;uintmax_t&lt;/tt&gt;), which needs work elsewhere in GCC
and a solution to the question of whether GCC or glibc should
be providing &lt;tt&gt;&amp;lt;stdint.h&amp;gt;&lt;/tt&gt;.  For example, with
GCC 3.0 you will be able to use &lt;tt&gt;%zu&lt;/tt&gt; formats for
&lt;tt&gt;size_t&lt;/tt&gt; values and so get rid of ugly casts to
&lt;tt&gt;unsigned long&lt;/tt&gt; that were previously needed for
portable code (as long as you don't need to support older
systems with pre-C99 libraries that don't understand &lt;tt&gt;%zu&lt;/tt&gt;;
glibc 2.1 is OK though there are a few C99 format features
it lacks, and glibc 2.2 will have an almost complete
implementation of the whole C99 standard library).  Details
of the standards versions in which features appeared are
now stored in data; all X/Open extensions and most glibc
extensions are supported.  The next stage is to move details
of the flags supported by each format type into data as well;
the eventual target is to allow a program to specify the
format rules for its own &lt;tt&gt;printf&lt;/tt&gt;-like functions.
(For example, a while ago on linux-kernel it was suggested
to add format extensions to format IP addresses with
&lt;tt&gt;printk&lt;/tt&gt;, but GCC couldn't check such extensions.
FreeBSD, with much closer control over the GCC used, has
such extensions and modifies GCC to add hardcoded support
for them.)</description>
    </item>
    <item>
      <pubDate>Tue, 1 Aug 2000 23:50:41 GMT</pubDate>
      <title>1 Aug 2000</title>
      <link>http://www.advogato.org/person/jsm28/diary.html?start=1</link>
      <guid>http://www.advogato.org/person/jsm28/diary.html?start=1</guid>
      <description>&lt;p&gt;C99 adds "type-generic macros" in &lt;tt&gt;&amp;lt;tgmath.h&amp;gt;&lt;/tt&gt;.
They feel much more like C++ than in the spirit of C, but
since they're in the standard glibc needs to implement them.
Implementing them needs compiler extensions; if you look
at the one glibc 2.1 installs you'll see macros using
&lt;tt&gt;__typeof__&lt;/tt&gt; and statement expressions that sort-of
work and sort-of make sense.  However, they get the behavior
for integer arguments completely wrong.

&lt;p&gt; &lt;p&gt;The other day I studied the matter and decided that a
fully correct implementation was impossible with the existing
GCC features and proposed some new compiler builtins to
allow for a clean implementation.  After a few mailing list
messages on how things might be achieved with other
extensions such as &lt;tt&gt;__builtin_classify_type&lt;/tt&gt;, I saw
how it could in fact be implemented.  The macros I produced
work, but are more obscure than even glibc's usual standard.
Now Ulrich Drepper has been crazy enough to include them
in glibc.

&lt;p&gt; &lt;pre&gt;
2000-08-01  Ulrich Drepper  &amp;lt;drepper@redhat.com&amp;gt;
            Joseph S. Myers  &amp;lt;jsm28@cam.ac.uk&amp;gt;

&lt;p&gt;         * math/tgmath.h: Make standard compliant.  Don't ask how.

&lt;p&gt; /* This is ugly but unless gcc gets appropriate builtins we have to do
   something like this.  Don't ask how it works.  */

&lt;p&gt; /* 1 if 'type' is a floating type, 0 if 'type' is an integer type.
   Allows for _Bool.  Expands to an integer constant expression.  */
#define __floating_type(type) (((type) 0.25) &amp;amp;&amp;amp; ((type) 0.25 - 1))

&lt;p&gt; /* The tgmath real type for T, where E is 0 if T is an integer type and
   1 for a floating type.  */
#define __tgmath_real_type_sub(T, E) \
  __typeof__(*(0 ? (__typeof__(0 ? (double *)0 : (void *)(E)))0               \
                 : (__typeof__(0 ? (T *)0 : (void *)(!(E))))0))

&lt;p&gt; /* The tgmath real type of EXPR.  */
#define __tgmath_real_type(expr) \
  __tgmath_real_type_sub(__typeof__(expr), __floating_type(__typeof__(expr)))
&lt;/pre&gt;

&lt;p&gt; &lt;p&gt;If &lt;tt&gt;__tgmath_read_type_sub&lt;/tt&gt; makes sense to anyone
without referring to some version or draft of the standard,
I'd be surprised; the rules used for the type of
conditional expressions are arcane.  If you try including
this header in C++ code, or try calling any of the macros
with complex integer types (a GCC extension), you'll get
what you deserve.  If you try nesting calls to the
type-generic macros, it should work - provided your
machine can cope with the code expansion involved, similar
to the problem of a harmless five nested calls to &lt;tt&gt;strcpy&lt;/tt&gt;
expanding to 200 Mbyte of text after preprocessing.  If
you actually &lt;em&gt;want&lt;/em&gt; to use such an obscure
&lt;tt&gt;&amp;lt;tgmath.h&amp;gt;&lt;/tt&gt;, you trust too much in the
compiler and in magic.

&lt;p&gt; &lt;p&gt;You are in a maze of twisty macros, headers, compiler
extensions and expensive standards, all different.</description>
    </item>
    <item>
      <pubDate>Mon, 24 Jul 2000 11:23:29 GMT</pubDate>
      <title>24 Jul 2000</title>
      <link>http://www.advogato.org/person/jsm28/diary.html?start=0</link>
      <guid>http://www.advogato.org/person/jsm28/diary.html?start=0</guid>
      <description>&lt;p&gt;My copy of the new C standard, ISO/IEC 9899:1999, finally arrived
today, five months after I ordered it.  This should (once I've spent a
day or two carefully reading the whole standard) help in documenting
the true &lt;a href="http://gcc.gnu.org/c99status.html" &gt;status of C99
implementation in GCC&lt;/a&gt; and in creating test cases for C99 features
and implementing or fixing some of them in GCC; up to now I've been
working from a PDF of the FDIS plus the editor progress report on
later changes.  Done so far: many test cases, general clean up of
C99-related documentation and parts of web pages, many fixes to
exactly what features are allowed in which &lt;tt&gt;-std&lt;/tt&gt; mode and to
the &lt;tt&gt;-pedantic&lt;/tt&gt; behaviour, many fixes to the &lt;tt&gt;printf&lt;/tt&gt;
format checking, the C99 names for &lt;tt&gt;long long&lt;/tt&gt; limits in
&lt;tt&gt;&amp;lt;limits.h&amp;gt;&lt;/tt&gt;.  Many other C99 features have already been
implemented by other people.

&lt;p&gt; &lt;p&gt;I consider that the standard is worth buying and reading for every
serious C programmer (though there will always be some people who make
confident pronouncements about C on mailing lists and Usenet that bear
no relation to its contents).  Drafts and books other than the
standard are best avoided for reference use.  The &lt;a
href="http://wwwold.dkuug.dk/JTC1/SC22/WG14/www/docs/summary.htm"&gt;Defect
Reports&lt;/a&gt; are also useful to give an idea of problem areas in the
standard.  The PDF version announced on 18 July may suffice if you
don't feel you want the "real thing" as printed and bound in
Switzerland.  The old standard in four parts is useful as well if you
can obtain it.

&lt;p&gt; &lt;p&gt;The five month delay arose thus: I had book token prizes from &lt;a
href="http://www.trin.cam.ac.uk/"&gt;Trinity College&lt;/a&gt; and wanted to
buy the printed C99 standard using them; this meant going via a
bookshop; &lt;a href="http://www.iso.ch/" &gt;ISO&lt;/a&gt; cause problems for
bookshops by requiring payment in advance and not giving discounts.
The bookshops I tried were unwilling or incompetent, even though
authorised to mark up the price as necessary to cover their profit
margins and costs: &lt;a href="http://www.heffers.co.uk/" &gt;Heffers&lt;/a&gt;
simply refused to handle ISO publications; &lt;a
href="http://www.waterstones.co.uk/"&gt;Waterstone's&lt;/a&gt; took the order
in February, but took four months after receiving a quote to get
payment to ISO, during which time they more than once told me that
payment had gone to ISO when it hadn't, failed to respond to emails or
to email me when they had said they would, and generally didn't make
any apparent progress until I got the manager of the branch involved
(this is a criticism of their overall systems that failed to handle
the order effectively, not of the individual staff involved).</description>
    </item>
  </channel>
</rss>
