You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@stdcxx.apache.org by "Martin Sebor (JIRA)" <ji...@apache.org> on 2008/11/15 18:45:44 UTC

[jira] Updated: (STDCXX-1024) ill-formed iostream code code in section 34.2 of User Guide

     [ https://issues.apache.org/jira/browse/STDCXX-1024?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor updated STDCXX-1024:
---------------------------------

    Description: 
As mentioned in this [post|http://markmail.org/message/36yuvstyykkgr3zo], the example program in section 34.2.3 -- Using Pointers or References to Streams of the User Guide is ill-formed:

{quote}
  at the very end of http://stdcxx.apache.org/doc/stdlibug/34-2.html
there is an example of using a reference to create a "copy" of cout.
However this example doesn't initialize the defined reference at once
(which is required in C++) and for this reason doesn't compile with my
gcc 4.2.1.

  For convenience here is the example:

{noformat}
int main(int argc, char *argv[])
{
  std::ostream& fr;
  if (argc > 1)
    fr = *(new std::ofstream(argv[1]));
  else
    fr = std::cout;

  fr << "Hello world!" << std::endl;

  if (&fr!=&std::cout)
    delete(&fr);
}
{noformat}
{quote}

  was:
As mentioned in this [post|http://markmail.org/message/36yuvstyykkgr3zo], the example program in section 34.2.3 -- Using Pointers or References to Streams of the User Guide is ill-formed:

{quote}
  at the very end of http://stdcxx.apache.org/doc/stdlibug/34-2.html
there is an example of using a reference to create a "copy" of cout.
However this example doesn't initialize the defined reference at once
(which is required in C++) and for this reason doesn't compile with my
gcc 4.2.1.

  For convenience here is the example:

int main(int argc, char *argv[])
{
  std::ostream& fr;
  if (argc > 1)
    fr = *(new std::ofstream(argv[1]));
  else
    fr = std::cout;

  fr << "Hello world!" << std::endl;

  if (&fr!=&std::cout)
    delete(&fr);
}
{quote}


Prevented formatting errors.

> ill-formed iostream code code in section 34.2 of User Guide
> -----------------------------------------------------------
>
>                 Key: STDCXX-1024
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1024
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: Documentation
>    Affects Versions: 4.2.1
>            Reporter: Martin Sebor
>            Assignee: Martin Sebor
>             Fix For: 4.2.2
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> As mentioned in this [post|http://markmail.org/message/36yuvstyykkgr3zo], the example program in section 34.2.3 -- Using Pointers or References to Streams of the User Guide is ill-formed:
> {quote}
>   at the very end of http://stdcxx.apache.org/doc/stdlibug/34-2.html
> there is an example of using a reference to create a "copy" of cout.
> However this example doesn't initialize the defined reference at once
> (which is required in C++) and for this reason doesn't compile with my
> gcc 4.2.1.
>   For convenience here is the example:
> {noformat}
> int main(int argc, char *argv[])
> {
>   std::ostream& fr;
>   if (argc > 1)
>     fr = *(new std::ofstream(argv[1]));
>   else
>     fr = std::cout;
>   fr << "Hello world!" << std::endl;
>   if (&fr!=&std::cout)
>     delete(&fr);
> }
> {noformat}
> {quote}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.