This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

### 444. Bad use of casts in fstream

Section: 31.10 [file.streams] Status: CD1 Submitter: Vincent Leloup Opened: 2003-11-20 Last modified: 2017-06-15

Priority: Not Prioritized

View all other issues in [file.streams].

View all issues with CD1 status.

Discussion:

31.10.3.4 [ifstream.members] p1, 31.10.4.4 [ofstream.members] p1, 31.10.5.4 [fstream.members] p1 seems have same problem as exposed in LWG issue 252.

Proposed resolution:

[Sydney: Genuine defect. 27.8.1.13 needs a cast to cast away constness. The other two places are stylistic: we could change the C-style casts to const_cast. Post-Sydney: Howard provided wording. ]

Change 27.8.1.7/1 from:

> Returns: (basic_filebuf<charT,traits>*)&sb.

to:

> Returns: const_cast<basic_filebuf<charT,traits>*>(&sb).

Change 27.8.1.10/1 from:

> Returns: (basic_filebuf<charT,traits>*)&sb.

to:

> Returns: const_cast<basic_filebuf<charT,traits>*>(&sb).

Change 27.8.1.13/1 from:

> Returns: &sb.

to:

> Returns: const_cast<basic_filebuf<charT,traits>*>(&sb).