-Werror=sign-conversion Triggered in blf_glyph.c #42797

Closed
opened 2014-12-04 03:15:52 +01:00 by Matt Runion · 11 comments

System Information
Arch Linux 64-bit -- latest updated, no TESTING
i7, 8GB RAM
nVidia GTX 870 6GB RAM
gcc 4.9.2-1
gcc-libs 4.9.2-1

Blender Version
Compiled latest from GIT: blender-git-56793.409043c-1

Short description of error
Build fails because of -Werror=sign-conversion triggered from blf_glyph.c lines 265 & 266

Exact steps for others to reproduce the error

The error I'm getting when compiling is:

/tmp/tmp.HuPKkPCapN/blender-git/src/blender/source/blender/blenfont/intern/blf_glyph.c: In function ‘blf_glyph_add’:
/tmp/tmp.HuPKkPCapN/blender-git/src/blender/source/blender/blenfont/intern/blf_glyph.c:265:13: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion]
  g->width = bitmap.width;
             ^
/tmp/tmp.HuPKkPCapN/blender-git/src/blender/source/blender/blenfont/intern/blf_glyph.c:266:14: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion]
  g->height = bitmap.rows;
              ^
cc1: some warnings being treated as errors
source/blender/blenfont/CMakeFiles/bf_blenfont.dir/build.make:123: recipe for target 'source/blender/blenfont/CMakeFiles/bf_blenfont.dir/intern/blf_glyph.c.o' failed
make[2]: *** [source/blender/blenfont/CMakeFiles/bf_blenfont.dir/intern/blf_glyph.c.o] Error 1
CMakeFiles/Makefile2:4889: recipe for target 'source/blender/blenfont/CMakeFiles/bf_blenfont.dir/all' failed
make[1]: *** [source/blender/blenfont/CMakeFiles/bf_blenfont.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

As you can see, the problem is that the setting -Werror=sign-conversion is catching an uncast type coersion. Lines 265 and 266 (where the error occurs) are:

265    g->width = bitmap.width;
266    g->height = bitmap.rows;

The problem is that g->width/height are type "int", but bitmap.wdith/height are type "unsigned int". That is causing the issue.

I changed the code in this file to:

265    g->width = (int)bitmap.width;
266    g->height = (int)bitmap.rows;

Blender compiled fine with these changes.

This error was NOT present on 11/6, but did start sometime after that. (I don't know the exact date, unfortunately.) It may be important to note that Arch Linux is a "rolling release", so we get the latest releases of packages from up stream. That means gcc is the latest released version. Again, I have no idea if that has anything to do with the issue, but it may be a contribution.

Thanks in advance for all you devs do for Blender!

**System Information** Arch Linux 64-bit -- latest updated, no TESTING i7, 8GB RAM nVidia GTX 870 6GB RAM gcc 4.9.2-1 gcc-libs 4.9.2-1 **Blender Version** Compiled latest from GIT: blender-git-56793.409043c-1 **Short description of error** Build fails because of -Werror=sign-conversion triggered from blf_glyph.c lines 265 & 266 **Exact steps for others to reproduce the error** The error I'm getting when compiling is: ``` /tmp/tmp.HuPKkPCapN/blender-git/src/blender/source/blender/blenfont/intern/blf_glyph.c: In function ‘blf_glyph_add’: /tmp/tmp.HuPKkPCapN/blender-git/src/blender/source/blender/blenfont/intern/blf_glyph.c:265:13: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion] g->width = bitmap.width; ^ /tmp/tmp.HuPKkPCapN/blender-git/src/blender/source/blender/blenfont/intern/blf_glyph.c:266:14: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion] g->height = bitmap.rows; ^ cc1: some warnings being treated as errors source/blender/blenfont/CMakeFiles/bf_blenfont.dir/build.make:123: recipe for target 'source/blender/blenfont/CMakeFiles/bf_blenfont.dir/intern/blf_glyph.c.o' failed make[2]: *** [source/blender/blenfont/CMakeFiles/bf_blenfont.dir/intern/blf_glyph.c.o] Error 1 CMakeFiles/Makefile2:4889: recipe for target 'source/blender/blenfont/CMakeFiles/bf_blenfont.dir/all' failed make[1]: *** [source/blender/blenfont/CMakeFiles/bf_blenfont.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... ``` As you can see, the problem is that the setting -Werror=sign-conversion is catching an uncast type coersion. Lines 265 and 266 (where the error occurs) are: ``` 265 g->width = bitmap.width; 266 g->height = bitmap.rows; ``` The problem is that g->width/height are type "int", but bitmap.wdith/height are type "unsigned int". That is causing the issue. I changed the code in this file to: ``` 265 g->width = (int)bitmap.width; 266 g->height = (int)bitmap.rows; ``` Blender compiled fine with these changes. This error was NOT present on 11/6, but did start sometime after that. (I don't know the exact date, unfortunately.) It may be important to note that Arch Linux is a "rolling release", so we get the latest releases of packages from up stream. That means gcc is the latest released version. Again, I have no idea if that has anything to do with the issue, but it may be a contribution. Thanks in advance for all you devs do for Blender!
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @mrunion

Added subscriber: @mrunion

Added subscriber: @mont29

Added subscriber: @mont29

Thanks for the report, will 'fix' this, but please do not use the tracker for such glitches, IRC (#blendercoders) or ML (bf-committers) should be used in such cases.

And those are warnings, you typically shall not error on them anyway.

Thanks for the report, will 'fix' this, but please do not use the tracker for such glitches, IRC (#blendercoders) or ML (bf-committers) should be used in such cases. And those are warnings, you typically shall not error on them anyway.

This issue was referenced by 2420a3c189

This issue was referenced by 2420a3c189951dbe910bd65e3b2c58082bfb4b1b

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit 2420a3c189.

Closed by commit 2420a3c189.
Author

Thank you for looking at this, and fixing it. Thanks also for the direction in reporting it to the proper place. (Though I disagree with your assessment that it's not a bug. But you're I charge and I'm not.)

Also, I do know this is a warning, but you'll notice that the -Werror=sign-conversion caused it to be treated as an error. That is why I called attention to the fact that I'm using gcc 4.9.2, because I haven't had this before, have no settings in my build config that enable it, see no explicit enable/disable of that error in the CMAKE configs, AND it appears that -Werror=sign-conversion needs explicitly disabled now.

I may be wrong in all this, but I am not that familiar with gcc and Blender code, but it seems something has changed in the latest gcc version.

Thanks again!

Thank you for looking at this, and fixing it. Thanks also for the direction in reporting it to the proper place. (Though I disagree with your assessment that it's not a bug. But you're I charge and I'm not.) Also, I do know this is a warning, but you'll notice that the -Werror=sign-conversion caused it to be treated as an error. That is why I called attention to the fact that I'm using gcc 4.9.2, because I haven't had this before, have no settings in my build config that enable it, see no explicit enable/disable of that error in the CMAKE configs, AND it appears that -Werror=sign-conversion needs explicitly disabled now. I may be wrong in all this, but I am not that familiar with gcc and Blender code, but it seems something has changed in the latest gcc version. Thanks again!

Ok, thanks for the precisions (gcc is sometimes becoming tediously pedantic about its 'treat-warnings-as-errors' defaults... though I guess being explicit in such cases is always a good thing anyway!).

Ok, thanks for the precisions (gcc is sometimes becoming tediously pedantic about its 'treat-warnings-as-errors' defaults... though I guess being explicit in such cases is always a good thing anyway!).

Added subscriber: @berndf

Added subscriber: @berndf

Note that gentoo was bitten by this as well: https://bugs.gentoo.org/show_bug.cgi?id=532640

Note that gentoo was bitten by this as well: https://bugs.gentoo.org/show_bug.cgi?id=532640
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#42797
No description provided.