public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/46641] New: Specification-expr checks and results with C_SIZEOF and SIZEOF
@ 2010-11-24 14:45 burnus at gcc dot gnu.org
2010-11-24 15:13 ` [Bug fortran/46641] " burnus at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-11-24 14:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46641
Summary: Specification-expr checks and results with C_SIZEOF
and SIZEOF
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
Kind of follow up to PR 46638; based on
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/1b907e3b7b6f3461
There is something fishy about the following program. In terms of validity, the
question is whether
C_SIZEOF (structure-constructor ())
is a valid initialization expression -- gfortran accepts it.
Besides the validity issue, there is something fishy. The "string" has a length
of 16 -- using either C_SIZEOF or the literal 16 in the declaration. However,
if one uses the literal, it works while using C_SIZEOF the TRANSFER seems to
override some memory it shouldn't - causing a segfault.
Using "sizeof()" instead of "c_sizeof()", the either version is rejected by the
Cray compiler - but both version work with ifort. Neither compiler likes the
C_sizeof version (not implemented in Cray, not sure about ifort).
gfortran prints for sizeof the error "must have constant character length" for
both versions.
module utils
use ISO_C_BINDING
implicit none
type, bind(C) :: CPUID_type
integer(C_INT32_T) eax
integer(C_INT32_T) ebx
integer(C_INT32_T) edx
integer(C_INT32_T) ecx
end type CPUID_type
type(CPUID_type) :: test_type
end module utils
program mxcsr_test
use ISO_C_BINDING
use utils
implicit none
integer(C_INT32_T) reg
integer(C_INT64_T) ts1, ts2
integer(C_INT16_T) sw, cw
integer(C_INT32_T) eax, ecx
type(CPUID_type) result
! Works:
! character(16) string
! Compiles but fails:
character(SIZEOF(CPUID_type(0,0,0,0))) string
! Rejected with: must have constant character length
! character(SIZEOF(test_type)) string
result = CPUID_TYPE(int(Z'0000000A'),int(Z'756E6547'), &
int(Z'49656E69'),int(Z'6C65746E'))
print *, len(string) ! OK: 16
string = transfer(result,string)
write(*,'(a,a)') 'Brand name: ',string(5:16)
write(*,'(4(z8.8:1x))') result
end program mxcsr_test
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46641] Specification-expr checks and results with C_SIZEOF and SIZEOF
2010-11-24 14:45 [Bug fortran/46641] New: Specification-expr checks and results with C_SIZEOF and SIZEOF burnus at gcc dot gnu.org
@ 2010-11-24 15:13 ` burnus at gcc dot gnu.org
2010-11-24 18:23 ` kargl at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-11-24 15:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46641
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |36437, 45824
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-11-24 14:53:27 UTC ---
(In reply to comment #0)
> In terms of validity, the question is whether
> C_SIZEOF (structure-constructor ())
> is a valid initialization expression -- gfortran accepts it.
I marked the PR now as regression as gfortran 4.5 accepts it - but does not
have the segfault issue at run time.
That issue seems to be related to the compile-time simplification - or rather
the lack of. Both 4.5 and 4.6 produce the dump:
character(kind=1) str[1:.str];
TODO:
a) Fix the issue above, cf. PR 36437
b) decide which of the various c_sizeof/sizeof is valid and thus should be
accepted or rejected; look also at the the thread (cf. comment 0) and in
particular at
http://groups.google.com/group/comp.lang.fortran/msg/8b36b578793b7037 , cf.
also PR 45824
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46641] Specification-expr checks and results with C_SIZEOF and SIZEOF
2010-11-24 14:45 [Bug fortran/46641] New: Specification-expr checks and results with C_SIZEOF and SIZEOF burnus at gcc dot gnu.org
2010-11-24 15:13 ` [Bug fortran/46641] " burnus at gcc dot gnu.org
@ 2010-11-24 18:23 ` kargl at gcc dot gnu.org
2010-11-27 22:20 ` burnus at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2010-11-24 18:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46641
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #2 from kargl at gcc dot gnu.org 2010-11-24 17:53:29 UTC ---
>From F2008, 13.1:
Intrinsic procedures are divided into seven classes: inquiry
functions, ...
Then one finds:
15.2.3.7 C SIZEOF (X)
Description. Size of X in bytes.
Class. Inquiry function.
Then from 7.1.11:
A specification inquiry is a reference to
...
(4) the function C_SIZEOF from the intrinsic module ISO_C_BINDING
(15.2.3.7), or
Then in "7.1.12 Constant Expression"
(4) a specification inquiry where each designator or function
argument is
(a) a constant expression or
So, c_sizeof() should be accepted by gfortran with -std=f2008 or gnu,
need to check f2003 whether -std=f2003 should accept it, and reject
for -std=f95.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46641] Specification-expr checks and results with C_SIZEOF and SIZEOF
2010-11-24 14:45 [Bug fortran/46641] New: Specification-expr checks and results with C_SIZEOF and SIZEOF burnus at gcc dot gnu.org
2010-11-24 15:13 ` [Bug fortran/46641] " burnus at gcc dot gnu.org
2010-11-24 18:23 ` kargl at gcc dot gnu.org
@ 2010-11-27 22:20 ` burnus at gcc dot gnu.org
2013-06-20 22:04 ` dominiq at lps dot ens.fr
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-11-27 22:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46641
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-11-27 21:57:01 UTC ---
The issue with specification issues is now fixed by PR 46678 (almost, not yet
committed). The TRANSFER issue was fixed as PR 46638.
Thus, remaining is only using C_SIZEOF - and by completeness - SIZEOF in
initialization expressions.
I think the latter is really tracked in PR 36437. Related is PR 45824.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46641] Specification-expr checks and results with C_SIZEOF and SIZEOF
2010-11-24 14:45 [Bug fortran/46641] New: Specification-expr checks and results with C_SIZEOF and SIZEOF burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2010-11-27 22:20 ` burnus at gcc dot gnu.org
@ 2013-06-20 22:04 ` dominiq at lps dot ens.fr
2013-06-20 22:07 ` dominiq at lps dot ens.fr
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-06-20 22:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46641
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2013-06-20
Ever confirmed|0 |1
--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
! Rejected with: must have constant character length
! character(SIZEOF(test_type)) string
This is the case up to revision 197010 (2013-03-23), but the code is accepted
after revision 197550 (2013-04-07). Can this PR be closed as FIXED?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46641] Specification-expr checks and results with C_SIZEOF and SIZEOF
2010-11-24 14:45 [Bug fortran/46641] New: Specification-expr checks and results with C_SIZEOF and SIZEOF burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2013-06-20 22:04 ` dominiq at lps dot ens.fr
@ 2013-06-20 22:07 ` dominiq at lps dot ens.fr
2013-12-14 20:13 ` dominiq at lps dot ens.fr
2013-12-14 20:25 ` dominiq at lps dot ens.fr
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-06-20 22:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46641
--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> This is the case up to revision 197010 (2013-03-23), but the code is
> accepted after revision 197550 (2013-04-07). Can this PR be closed as FIXED?
Likely revision 197053.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46641] Specification-expr checks and results with C_SIZEOF and SIZEOF
2010-11-24 14:45 [Bug fortran/46641] New: Specification-expr checks and results with C_SIZEOF and SIZEOF burnus at gcc dot gnu.org
` (4 preceding siblings ...)
2013-06-20 22:07 ` dominiq at lps dot ens.fr
@ 2013-12-14 20:13 ` dominiq at lps dot ens.fr
2013-12-14 20:25 ` dominiq at lps dot ens.fr
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-12-14 20:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46641
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
No feedback since almost six months. Closing as FIXED. Please open a new PR if
I have missed any remaining issue.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/46641] Specification-expr checks and results with C_SIZEOF and SIZEOF
2010-11-24 14:45 [Bug fortran/46641] New: Specification-expr checks and results with C_SIZEOF and SIZEOF burnus at gcc dot gnu.org
` (5 preceding siblings ...)
2013-12-14 20:13 ` dominiq at lps dot ens.fr
@ 2013-12-14 20:25 ` dominiq at lps dot ens.fr
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-12-14 20:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46641
Bug 46641 depends on bug 45824, which changed state.
Bug 45824 Summary: Update expr.c's check_inquiry for C_SIZEOF, compiler_version/_options, etc.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45824
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |FIXED
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-12-14 20:25 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-24 14:45 [Bug fortran/46641] New: Specification-expr checks and results with C_SIZEOF and SIZEOF burnus at gcc dot gnu.org
2010-11-24 15:13 ` [Bug fortran/46641] " burnus at gcc dot gnu.org
2010-11-24 18:23 ` kargl at gcc dot gnu.org
2010-11-27 22:20 ` burnus at gcc dot gnu.org
2013-06-20 22:04 ` dominiq at lps dot ens.fr
2013-06-20 22:07 ` dominiq at lps dot ens.fr
2013-12-14 20:13 ` dominiq at lps dot ens.fr
2013-12-14 20:25 ` dominiq at lps dot ens.fr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).