Re: csc (C# Compiler) bug

From: Daniel O'Connell [C# MVP] (onyxkirx_at_--NOSPAM--comcast.net)
Date: 06/03/04


Date: Thu, 3 Jun 2004 12:22:46 -0500


"Paul Reeder" <paul@reeder.ws> wrote in message
news:52D3A0D0-C1A7-45EA-8555-F4C597F827D5@microsoft.com...
>I hope that MS watches this newsgroup.
>
> I seem to have found a bug in csc. I am compiling from VS.NET 2003. The
> csc version information (from command line) is:
> Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
> for Microsoft (R) .NET Framework version 1.1.4322
> Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
>
> In my application, I am using some custom display options that use
> non-standard characters as special icons, and often have strings which
> have characters >0x80. When used as a constant, these do not compile
> properly. Here is some source that does not compile properly:
> private const string DELETE = " \x84DELETE";
>
> Using ildasm to view the MSIL, I see:
> .field private static literal string DELETE = bytearray (20 00 DE 84 4C 00
> 45 00 54 00 45 00 ) // ...L.E.T.E.
>
> Definitely not what is expected! This does not happen with all strings
> which contain '\x84' followed by other characters. In fact, I have only
> seen it twice, with the example above and with " \x84Acknowledge".
>

Its not a bug, its actually correct. In both cases, it is assuming you mean
the hex string 84de and 84ac instead of 84. The \x is a variant length
escape sequence, there is no other way to do this.
You should probably use \u, which is fixed length, instead,
private const string DELETE = "\u0084DELETE";

otherwise you will have to concatenate.

This is also not related to being greater than 80, I was able to reproduce
it using the string "\x12delete"

> At runtime, such strings can be built using contatenation, as shown in the
> code below:
> private static bool _SMANI_HACK = false;
> private static string DELETE = "DELETE";
> public <.ctor>(...)
> {
> //HACK: FIXED MICROSOFT >0x80 bug (?)
> if (!_SMANI_HACK)
> {
> _SMANI_HACK = true;
> DELETE = " \x84" + DELETE;
> }
> //normal constructor information
> }
>
> But of course, this only really works for private constants, since others
> may be called before any instances are instantiated (calling constructor).
> The other way would be to buffer these strings behind a static property,
> and though that would probably work, it seems like it would be a severe
> performance hit.
>
> I suppose another work around would be to manually modify the MSIL, but
> this really seems extreme, and not something that one wants to have to
> remember to do for a product that may be in a state of flux.
>
> Any information would be appreciated.
>



Relevant Pages

  • Re: csc (C# Compiler) bug
    ... > I seem to have found a bug in csc. ... these do not compile properly. ... This does not happen with all strings ... literal string begins a hexadecimal escape sequence. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A note on computing thugs and coding bums
    ... Here's my response including a bug fix. ... to make "modern strings" possible was designed and first implemented ... contents to strings, to compare them, and to duplicate them. ... while the Pike code will NEVER work...for international strings. ...
    (comp.programming)
  • Re: Why leave the error handling to the caller?
    ... I didn't even mention the fact that it didn't compile. ... If the intended behavior of the program is to simply output all the strings with no further processing there would never be any reason for storing them and whatever is in the error recovery part of the program would better be the *entire* program. ... I assume the purpose of allocating the strings in some structure to begin with is that there really is some further processing to be done before outputting them. ... That would make the error handling function output data that would be wrong. ...
    (comp.lang.c)
  • Re: Pedants
    ... it was a genuine bug. ... no reason to assume that gcc-specific headers will compile with any ... If some gcc-specific header didn't compile with gcc, ... general container library for instance. ...
    (comp.lang.c)
  • Re: automated test? (was Re: Linux 2.6.17.7)
    ... a bug report may not convey the hint "look at this NOW, ... what I was intending with my origional question was a series of simple 'does it compile' tests that try all the config options that are affected by the patchset in question. ... obviously such a test can't be done on the huge -rc patches, but for -stable patches ... Given a patch that modifies file X is it possible to know what config options could be affected? ...
    (Linux-Kernel)