Fix #14743 (New check: ftell() result is unspecified when file is opened in mode "t")#8360
Fix #14743 (New check: ftell() result is unspecified when file is opened in mode "t")#8360damorinCan wants to merge 1 commit into
Conversation
|
Thanks for your contribution. |
|
Title now including reference to C11 and removed reference to Windows 11.
I added a test in test/testio.cpp. Anything missing in it ? |
Thanks, I must have missed that. |
|
Ping @danmar |
danmar
left a comment
There was a problem hiding this comment.
I feel we need to have a ticket for this in trac
it feels like it should be added to the release notes as a "new check" ?
|
I have tried to add some descriptions about some of our checkers here: Ideally that would contain descriptions for all our checkers but due to lack-of-resources it does not. If you can add a corresponding file for this checking that would be great. |
|
|
We need a ticket in trac for this. Can you please tell me what you think the summary and description should be and we can create it.. |
Thanks, I lost my login/password (last time was years ago). What about this: [ftell() is no more returning the correct offset on a text file with Windows 11 compared to Linux. |
do you remember your username? If you send me a new htpasswd hash via email I can update.. |
|
The PR title should be something like: Fix #14743 (ftell() not consistent in C11) I would like that the PR title and ticket title are consistent. and well imho the fundamental issue is not that linux/windows does not have the same behavior. the fundamental issue is that the behavior is implementation defined. it's possible you can have different behavior when using the same compiler but different volume type, compiler flags, etc.. |
|
Hi,
I tried to edit the ticket title but it's not possible so I made the PR
title the same as the ticket.
Robert
Le lun. 11 mai 2026 à 05:33, Daniel Marjamäki ***@***.***> a
écrit :
… *danmar* left a comment (cppcheck-opensource/cppcheck#8360)
<#8360 (comment)>
The PR title should be something like:
Fix #14743 (ftell() not consistent in C11)
I would like that the PR title and ticket title are consistent.
—
Reply to this email directly, view it on GitHub
<#8360 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB2AXDMB3H3KXMOCKNN3DTD42GM7ZAVCNFSM6AAAAACW2EKWFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DIMJZGMYDOMRVHE>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
| void CheckIO::ftellFileError(const Token *tok) | ||
| { | ||
| reportError(tok, Severity::portability, | ||
| "ftellTextModeFile", "The ftell function obtains the current value of the file position indicator" |
There was a problem hiding this comment.
sorry but I want to change...
This is not a good warning message. How about:
ftell() result is unspecified when file is opened in mode "t"
I want that the standard text is quoted in the ftellTextModeFile.md file.
|
Could you add a note about this in the releasenotes? In my opinion we can say it's a new check. Technically it's not but it's a completely new type of warning. |
…"t". New changes: - Added missing string related to new check - Added checker description for ftellTextModeFile - Updated releasenotes.txt with new check
| FILE *f = fopen("Example.txt", "rt"); | ||
| if (f) | ||
| { | ||
| int position; |
There was a problem hiding this comment.
these variables position and st are not needed
| if (f) | ||
| { | ||
| fseek(f, 0, SEEK_END); | ||
| printf( "Offset %d\n", ftell(f); |
There was a problem hiding this comment.
I suggest that the "After" example matches the "Good" example except the file mode.
|
|
||
| ## Description | ||
|
|
||
| This checker detects the use of ftell() on a file open in text (or translate) mode. The text mode is not consistent |
There was a problem hiding this comment.
I would like that we provide the text from the standard . You only reference the windows documentation, that is not as strong and important as the standard. and also I feel it's misleading to point at windows this is an issue you should be aware of no matter what platform you compile on.



Some legacy tools stopped suddenly working after 20+ years.
https://stackoverflow.com/questions/79762122/ftell-no-more-returning-the-correct-offset-on-a-text-file-with-windows-11-ente
Trac ticket: https://trac.cppcheck.net/ticket/14743#ticket