Skip to content
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

fix: manually cast file size to std::streamsize #258

Merged
merged 1 commit into from
Jul 21, 2024

Conversation

pinotree
Copy link
Contributor

When reading a file to vector, manually cast the file size (represented as std::streamoff hidden as auto) to std::streamsize, which is the type for std::istream::read(); this avoids the warning/error

  error: conversion from ‘long long int’ to ‘std::streamsize’ {aka ‘int’} may change value [-Werror=conversion]

This means a truncation happens on 32bit architectures, however that seems a limitation of the standard library.

When reading a file to vector, manually cast the file size (represented
as std::streamoff hidden as auto) to std::streamsize, which is the type
for std::istream::read(); this avoids the warning/error

  error: conversion from ‘long long int’ to ‘std::streamsize’ {aka ‘int’} may change value [-Werror=conversion]

This means a truncation happens on 32bit architectures, however that
seems a limitation of the standard library.
@ToruNiina ToruNiina merged commit 4dd83fe into ToruNiina:main Jul 21, 2024
144 checks passed
@ToruNiina
Copy link
Owner

Nice catch! Thank you!

github-actions bot pushed a commit that referenced this pull request Jul 21, 2024
fix: manually cast file size to std::streamsize 4dd83fe
@pinotree pinotree deleted the read-streamsize branch July 21, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants