-
Notifications
You must be signed in to change notification settings - Fork 1.6k
ftell() not consistent in C11 #8360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ class TestIO : public TestFixture { | |
| TEST_CASE(fileIOwithoutPositioning); | ||
| TEST_CASE(seekOnAppendedFile); | ||
| TEST_CASE(fflushOnInputStream); | ||
| TEST_CASE(ftellCompatibility); | ||
| TEST_CASE(incompatibleFileOpen); | ||
|
|
||
| TEST_CASE(testScanf1); // Scanf without field limiters | ||
|
|
@@ -704,6 +705,21 @@ class TestIO : public TestFixture { | |
| ASSERT_EQUALS("", errout_str()); // #6566 | ||
| } | ||
|
|
||
| void ftellCompatibility() { | ||
|
|
||
| check("void foo() {\n" | ||
| " FILE *f = fopen(\"\", \"rt\");\n" | ||
| " if (f)\n" | ||
| " {\n" | ||
| " fseek(f, 0, SEEK_END);\n" | ||
| " (void)ftell(f);\n" | ||
| " fclose(f);\n" | ||
| " }\n" | ||
| "}\n", dinit(CheckOptions, $.platform = Platform::Type::Win32A, $.portability = true)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test what happens on unix platform . test what happens when C99 is used - that works as expected right?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Selecting Win32A is too limiting, it should apply to all platforms for portability. |
||
| ASSERT_EQUALS("[test.cpp:6:16]: (portability) For a text stream, its file position indicator contains unspecified information. See Section 7.21.9.4p2 of the C11 standard [ftellTextModeFile]\n", errout_str()); | ||
| } | ||
|
|
||
|
|
||
| void fflushOnInputStream() { | ||
| check("void foo()\n" | ||
| "{\n" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the error message says something about the C11 standard. Nothing about windows.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a comment about this reference to this Microsoft page:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/ftell-ftelli64?view=msvc-170
An update for the error message with this, would it be OK ?
I will remove the reference to _wfopen(), it's not part of the C++ standard.