Bug 1017 – CTFE doesn't support (string == string)
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-03-03T06:32:00Z
Last change time
2014-02-16T15:25:45Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
reiner.pope
Comments
Comment #0 by reiner.pope — 2007-03-03T06:32:51Z
The following code fails in DMD 1.007:
void main()
{
static assert(equals("alphabet", "alphabet"));
}
bool equals(char[] a, char[] b)
{
return (a == b);
}
equality.d(3): static assert (equals("alphabet","alphabet")) is not evaluatable
at compile time
Comment #1 by bugzilla — 2007-03-03T12:51:50Z
Put equals() before main() and it should work.
Comment #2 by fvbommel — 2007-03-03T13:00:37Z
(In reply to comment #1)
> Put equals() before main() and it should work.
It doesn't:
---
urxae@urxae:~/tmp$ cat test.d
bool equals(char[] a, char[] b)
{
return (a == b);
}
void main()
{
static assert(equals("alphabet", "alphabet"));
}
urxae@urxae:~/tmp$ dmd test.d
test.d(8): static assert (equals("alphabet","alphabet")) is not evaluatable at compile time
---
Comment #3 by smjg — 2007-03-04T13:04:31Z
(In reply to comment #1)
> Put equals() before main() and it should work.
Under which platform did you observe a dependency on the order of declarations in this instance? Clearly not that on which the reporter reported the problem.
Comment #4 by fvbommel — 2007-03-04T13:19:38Z
(In reply to comment #3)
> (In reply to comment #1)
> > Put equals() before main() and it should work.
>
> Under which platform did you observe a dependency on the order of declarations
> in this instance? Clearly not that on which the reporter reported the problem.
Actually, it could be the same as the reporter. My test of Walter's theory was done on Linux, while the reporter is appears to be using Windows.
I have no idea if it works on Windows if the order is switched, but I _can_ confirm this bug on Linux, so I'll just change the OS setting to 'all'...
Comment #5 by aldacron — 2007-03-05T02:55:25Z
[email protected] wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=1017
>
>
> [email protected] changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> OS/Version|Windows |All
>
>
>
>
> ------- Comment #4 from [email protected] 2007-03-04 13:19 -------
> (In reply to comment #3)
>> (In reply to comment #1)
>>> Put equals() before main() and it should work.
>> Under which platform did you observe a dependency on the order of declarations
>> in this instance? Clearly not that on which the reporter reported the problem.
>
> Actually, it could be the same as the reporter. My test of Walter's theory was
> done on Linux, while the reporter is appears to be using Windows.
> I have no idea if it works on Windows if the order is switched, but I _can_
> confirm this bug on Linux, so I'll just change the OS setting to 'all'...
>
>
That's correct. I haven't found any configuration where it compiles
under Windows -- and I tried pretty hard to get around this one... for
example, slicing the arrays does not help. Even this (arguably simpler)
variation doesn't work:
bool a()
{
return "x"!="y";
}
void main()
{
static assert( a() );
}