Red Hat Bugzilla – Bug 57546
Sources won't compile with more strict compiler
Last modified: 2007-04-18 12:38:43 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Description of problem:
Let we look into ghostscript-6.51 sources.
File "ghostscript-6.51/src/eplaser/gdevesmv.c", function "private int
There are two local variables (line 1508, 1509):
gx_device_vector const *vdev = (gx_device_vector *) dev;
gx_device_esmv const *pdev = (gx_device_esmv *) dev;
As there is written this is the pointers to const struct. But we can see
in subsequent lines:
(line 1531) pdev->current_color = color;
(line 1547) pdev->MaskState = 1;
There is modifying of constant value (gcc allows it in plain C) and gcc
emits warning on it:
./src/gdevesmv.c:1531: warning: assignment of read-only member
More strict compiler (in example Intel Proton compiler) would produce
error on this, so you should remove 'const' qualifier on these variables
in order to increase Red Hat Linux portability.
P.S.: maybe author wanted to declare const pointer to structures - it can
be made so:
gx_device_vector * const vdev = (gx_device_vector *) dev;
and there will be no error or warning emitted.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
If you haven't Intel compiler (icc) you will not be able to reproduce this
If you have Intel compiler:
1. Make sure, that Intel compiler will be called instead of gcc, g++ and
2. Install ghostscript-6.51-12.src.rpm. (-i option for rpm).
3. icc doesn't support complicated vla's - i make
patch 'src_vla.patch'(attached) which helps you avoid possible errors
concerned with this.
4. Try to build ghostscript.spec (-bc option for rpm) and get an error
Actual Results: Error message will be emitted:
"./src/gdevesmv.c", line 1531: error: expression must be a modifiable
pdev->current_color = color;
Expected Results: Succesfully builded ghostscript package.
Created attachment 40730 [details]
Patch for ghostscript sources for compilers which doesn't support complicated variable length arrays
Created attachment 40887 [details]
I correct errors arised and now ghostscript build succesfully. I attach this patch (previous one about vla is already attached) to ease your work for make Red Hat Linux more portable.
Thanks for the patch.
Filed upstream (sf #515966). I'd rather wait until this filters through via an
upstream release, since this is for non-GCC builds only (and we build our
packages with GCC).