home.social

#cstandard — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #cstandard, aggregated by home.social.

fetched live
  1. It turns out that sometime ago #gcc has added the #clang attribute #may_alias to C (and C++). After breaking C semantics, despite clear objections from Dennis Ritchie, to enable unquantified and feeble "optimizations" based on aliasing, the compiler bosses have had to smuggle back a version. Looks like these changes went into some of libc about a year ago.
    #wg14 #Cstandard

  2. It turns out that sometime ago #gcc has added the #clang attribute #may_alias to C (and C++). After breaking C semantics, despite clear objections from Dennis Ritchie, to enable unquantified and feeble "optimizations" based on aliasing, the compiler bosses have had to smuggle back a version. Looks like these changes went into some of libc about a year ago.
    #wg14 #Cstandard

  3. One feature C has needed forever is a solution to replace va_args, which is a super ugly hack that is hard to optimize around. Dennis Ritchie asked for one, but it's not the kind of tinkering that earns points in WG14.

    Another, much simpler, feature would be to actually define "asm" which is ubiquitous in C code, but according the current standard means nothing. Even if you defined most of it as implementation dependent, that would be an improvement and would allow for more reliable optimization.

    #C #Clang #Cstandard #Cfeature

  4. One feature C has needed forever is a solution to replace va_args, which is a super ugly hack that is hard to optimize around. Dennis Ritchie asked for one, but it's not the kind of tinkering that earns points in WG14.

    Another, much simpler, feature would be to actually define "asm" which is ubiquitous in C code, but according the current standard means nothing. Even if you defined most of it as implementation dependent, that would be an improvement and would allow for more reliable optimization.

    #C #Clang #Cstandard #Cfeature

  5. If we are going to add features to C, they should be useful. Here are four simple ones
    1. reverse void *
    T x = ....

    f( (void *)&x);
    ....

    f(void * y){
    T *z= (reverse-void*) y;
    ...

    Where the compiler can complain it can't reverse the cast if the caller code is too obscure.

    2. sequence-point;
    No code in the text prior to the point can be moved past it.

    3. strict typedef
    strict_typedef unsigned int centimeters
    strict typedef unsigned int inches

    inches x; centimeters y;
    ...

    get a compile error on x=y or
    x>y etc.

    ok: u i=x; y = 5* (i >>1) + (i&1);

    4. Option opt-in
    gives a standardized in text equivalent of certain compile flags

    #c #clang #Cstandard

  6. If we are going to add features to C, they should be useful. Here are four simple ones
    1. reverse void *
    T x = ....

    f( (void *)&x);
    ....

    f(void * y){
    T *z= (reverse-void*) y;
    ...

    Where the compiler can complain it can't reverse the cast if the caller code is too obscure.

    2. sequence-point;
    No code in the text prior to the point can be moved past it.

    3. strict typedef
    strict_typedef unsigned int centimeters
    strict typedef unsigned int inches

    inches x; centimeters y;
    ...

    get a compile error on x=y or
    x>y etc.

    ok: u i=x; y = 5* (i >>1) + (i&1);

    4. Option opt-in
    gives a standardized in text equivalent of certain compile flags

    #c #clang #Cstandard