Topic: Standardization of non-standard features


Author: Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
Date: 2000/01/22
Raw View
Reico GmbH <Entwicklung@reico.de> writes:

[...]

| int foo () return result {
|   // result is treated as a local variable
|   return; // means: return result;
| }

That is a *hack* that was introduced in g++ to manually implement the
infamous 'return value optimization'.

--
Gabriel Dos Reis, dosreis@cmla.ens-cachan.fr

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Alex Vinokur <alexander.vinokur@telrad.co.il>
Date: 2000/01/05
Raw View
In article <386fac89@eeyore.callnetuk.com>,
  "Chris Newton" <not@all.likely> wrote:
> Alex Vinokur <alexander.vinokur@telrad.co.il> wrote...
> > The following construction is valid
    in gcc/g++ compiler
 See my original message :
 http://www.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=567342296
>
> [snip]
>
> >
> >
> > int main ()
> > {
> >         foo (10, 200, 3000);
> >         return 0;
> > }
>
> Sorry, but no, that's not valid. Please see the C++ Standard, sections
> 8.3.4 (on arrays) and 5.19 (on the definition of an integral constant
> expression).
>
> Cheers,
> Chris
>
>

GNU compiler (gcc/g++/egcs) contains several advanced non-standard
features. For instance,
 1. void foo (int s1, int s2, int s3)
    {
  char    aaa [s1] [s2] [s3];
    }
    That code is legal in g++.

 2. switch (value)
    {
  case 1 :
   break;

  case 100 ... 200 : // Legal in g++
   break;
    }

 3. __PRETTY_FUNCTION__
      --FUNCTION__

 (Does anybody know something else?)

(I think) All these feature are very useful.
Of course we have to realize that they are non-standard.
By the way, is it worth standardizing them?

 Alex






Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Reico GmbH <Entwicklung@reico.de>
Date: 2000/01/06
Raw View
Hi,

> (I think) All these feature are very useful.
> Of course we have to realize that they are non-standard.
> By the way, is it worth standardizing them?

And the C++Builder-Community want to standardize the __property -
Feature (also very useful) and, and, and ...
But by now no compiler fits the current standard rules right - IMHO this
would be more useful.

BTW:
>         (Does anybody know something else?)
I'm not sure:

int foo () return result {
  // result is treated as a local variable
  return; // means: return result;
}


Best regards
Olaf Krzikalla
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: "Frans E. van Dorsselaer" <frans@bia-bv.demon.nl>
Date: 2000/01/07
Raw View
Reico GmbH wrote:
> I'm not sure:
>
> int foo () return result {
>   // result is treated as a local variable
>   return;       // means: return result;
> }

Hmm, let me rewrite that (note the reuse of your comments):

int foo () {
  int result; // result is treated as a local variable
  return result; // means: return result;
}

I think named returns (gcc has those as an extension) can already
be accomplished without much extra work.  IMHO the benefits are
too little to validate new syntax.

Frans


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]