Bug 39312 - parameter (constant) and initialization with hex values
Summary: parameter (constant) and initialization with hex values
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 39313 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-02-26 14:32 UTC by Rune Vatnehagen
Modified: 2009-02-26 15:10 UTC (History)
2 users (show)

See Also:
Host: sparc-sun-solaris2.8
Target: sparc-sun-solaris2.8
Build: sparc-sun-solaris2.8
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rune Vatnehagen 2009-02-26 14:32:39 UTC
How can initialization of a parameter (constant) with hex values be done?

I.e. I would like to write "parameter (xx = z'ff')" 
or 
integer, parameter :: zz=z'022'
but the compiler complains over "BOZ used outside a data statement"
Comment 1 kargls 2009-02-26 14:42:38 UTC
You need to give some details, including a small program,
the compiler command line you used, and the output of 
gfortran -v.

Because it works for me.

laptop:kargl[6] cat > a.f
       program z
       integer j
       parameter (j = z'ff')
       print *, j
       end program z
^Dlaptop:kargl[7] 
laptop:kargl[7] gfc43 -o z a.f
laptop:kargl[8] ./z
         255
Comment 2 Rune Vatnehagen 2009-02-26 14:59:04 UTC
(In reply to comment #1)
> You need to give some details, including a small program,
> the compiler command line you used, and the output of 
> gfortran -v.
> 
> Because it works for me.
> 
> laptop:kargl[6] cat > a.f
>        program z
>        integer j
>        parameter (j = z'ff')
>        print *, j
>        end program z
> ^Dlaptop:kargl[7] 
> laptop:kargl[7] gfc43 -o z a.f
> laptop:kargl[8] ./z
>          255
> 

(In reply to comment #1)
> You need to give some details, including a small program,
> the compiler command line you used, and the output of 
> gfortran -v.
> 
> Because it works for me.
> 
> laptop:kargl[6] cat > a.f
>        program z
>        integer j
>        parameter (j = z'ff')
>        print *, j
>        end program z
> ^Dlaptop:kargl[7] 
> laptop:kargl[7] gfc43 -o z a.f
> laptop:kargl[8] ./z
>          255
> 


>gfortran -v
Using built-in specs.
Target: sparc-sun-solaris2.8
Configured with: /t3-0/shared/gnu/gcc-4.3.3/configure --prefix=/t3-0/shared/gnu/gcc-trunk --srcdir=/t3-0/shared/gnu/gcc-4.3.3 --enable-languages=c,fortran --with-mpfr=/usr/local --with-gmp=/usr/local --with-pkgversion=432
Thread model: posix
gcc version 4.3.3 (432) 


program:
>cat rv1.f
       SUBROUTINE SLSYNOF(TSN,UFD,STATUS)

       INCLUDE 'rvp.mnc'

! --   DO something
       RETURN

       END


includefile:
>cat rvp.mnc 
! includefile

      PARAMETER (SL_I4NOVALUE = Z'80000000')
!      INTEGER :: SL_I4NOVALUE
!      DATA SL_I4NOVALUE / Z'80000000'/
!      PARAMETER (SL_I4NOVALUE = SL_I4NOVALUED )

!      integer, parameter :: ipm = 2
!      data ipm /z'033'/





running:
>gfortran -g -std=f95 -ffree-form -frange-check -c rv1.f90  -o rv1.o
rvp.mnc:3.43:
    Included at rv1.f90:2:

      PARAMETER (SL_I4NOVALUE = Z'80000000')
                                           1
Error: Fortran 2003: BOZ used outside a DATA statement at (1)


Comment 3 Steve Kargl 2009-02-26 15:09:17 UTC
Subject: Re:  parameter (constant) and initialization with hex values

On Thu, Feb 26, 2009 at 02:59:05PM -0000, rvatne at gmail dot com wrote:
> 
> running:
> >gfortran -g -std=f95 -ffree-form -frange-check -c rv1.f90  -o rv1.o
> rvp.mnc:3.43:
>     Included at rv1.f90:2:
> 
>       PARAMETER (SL_I4NOVALUE = Z'80000000')
>                                            1
> Error: Fortran 2003: BOZ used outside a DATA statement at (1)
> 

You got exactly what you asked the compiler to do.
Remove the -std=f95 option if you don't want to 
enforce the Fortran 95 standard.

Comment 4 Richard Biener 2009-02-26 15:09:45 UTC
*** Bug 39313 has been marked as a duplicate of this bug. ***
Comment 5 kargls 2009-02-26 15:10:42 UTC
BOZ are allowed in data statements only in Fortran 95.